Javascript opens links in new window

08-20-03, 03:48 PM
|
|
New Member
|
|
Join Date: Aug 2003
Location: Hampshire, UK
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Javascript opens links in new window
Hello,
For the navigation on my website I hope to use the following menu ( http://www.podman-racing.co.uk/ssi/n...nbar/menu.html), but ive got a bit of a problem with it, the links on the drop-down boxes always open in a new wondow, which is of course a bit of a pain!
I made the menu with a trial piece of software (XARA menu maker) and the company doesnt have any help files or anything that can help me. Im a bit of a n00b on javascript so I would be grateful for any help with changing the script so that it opens the links in the same window.
Cheers
Podman
HTML
Quote:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MenuMaker produced NavBar</title>
</head>
<body bgcolor="#ffffff" text="BLACK">
<img src="podman-racing.jpg">
<script src="xaramenu.js"></script><script menumaker src="menu_.js"></script>
</body></html>
|
Menu_.js
Quote:
if(typeof(loc)=="undefined"||loc==""){var loc="";if(document.body&&document.body.innerHTML){ var tt=document.body.innerHTML.toLowerCase();var last=tt.indexOf("menu_.js\"");if(last>0){var first=tt.lastIndexOf("\"",last);if(first>0&&first< last)loc=document.body.innerHTML.substr(first+1,la st-first-1);}}}
var bd=1
document.write("<style type=\"text/css\">");
document.write("\n<!--\n");
document.write(".menu__menu {border-color:#000000;border-style:solid;border-width:"+bd+"px 0px "+bd+"px 0px;background-color:#00ccff;position:absolute;left:0px;top:0px;v isibility:hidden;}");
document.write("a.menu__plain:link, a.menu__plain:visited{text-align:left;background-color:#00ccff;color:#000000;text-decoration:none;border-color:#000000;border-style:solid;border-width:0px "+bd+"px 0px "+bd+"px;padding:2px 0px 2px 0px;cursor:hand;display:block;font-size:10pt;font-family:Tahoma, Verdana, Arial, sans-serif;}");
document.write("a.menu__plain:hover, a.menu__plain:active{background-color:#0000ff;color:#ffffff;text-decoration:none;border-color:#000000;border-style:solid;border-width:0px "+bd+"px 0px "+bd+"px;padding:2px 0px 2px 0px;cursor:hand;display:block;font-size:10pt;font-family:Tahoma, Verdana, Arial, sans-serif;}");
document.write("\n-->\n");
document.write("</style>");
var fc=0xffffff;
var bc=0x0000ff;
if(typeof(frames)=="undefined"){var frames=0;}
startMainMenu("",0,0,2,0,0)
mainMenuItem("menu__b1",".gif",19,83,"http://www.podman-racing.co.uk","","Home Page",2,2,"menu__plain");
mainMenuItem("menu__b2",".gif",19,46,"javascript:; ","","Storm",2,2,"menu__plain");
mainMenuItem("menu__b3",".gif",19,54,"javascript:; ","","Gallery",2,2,"menu__plain");
mainMenuItem("menu__b4",".gif",19,71,"javascript:; ","","The Team",2,2,"menu__plain");
mainMenuItem("menu__b5",".gif",19,47,"javascript:; ","","Trade",2,2,"menu__plain");
mainMenuItem("menu__b6",".gif",19,41,"javascript:; ","","Links",2,2,"menu__plain");
mainMenuItem("menu__b7",".gif",19,59,"javascript:; ","","Reviews",2,2,"menu__plain");
mainMenuItem("menu__b8",".gif",19,75,"http://www.podman-racing.co.uk/forum/index.php?showforum=19","(none)","Prototypes",2,2, "menu__plain");
mainMenuItem("menu__b9",".gif",19,77,"http://www.podman-racing.co.uk/forum/index.php?showforum=18","(none)","Downloads",2,2," menu__plain");
mainMenuItem("menu__b10",".gif",19,51,"http://www.podman-racing.co.uk/forum/index.php?showforum=17","(none)","Guides",2,2,"men u__plain");
mainMenuItem("menu__b11",".gif",19,57,"javascript: ;","","Services",2,2,"menu__plain");
mainMenuItem("menu__b12",".gif",19,50,"http://www.podman-racing.co.uk/forum/","(none)","Forum",2,2,"menu__plain");
endMainMenu("",0,0);
startSubmenu("menu__b11","menu__menu",107);
submenuItem("Advertising","http://www.podman-racing.co.uk/forum/index.php?showtopic=2","(none)","menu__plain");
submenuItem("Product reviews","http://www.podman-racing.com/forum/index.php?showtopic=7","(none)","menu__plain");
submenuItem("Kit prototypes","http://www.podman-racing.co.uk/forum/index.php?showtopic=6","(none)","menu__plain");
submenuItem("website design","http://www.podman-racing.co.uk/forum/index.php?act=ST&f=8&t=18","(none)","menu__plain") ;
endSubmenu("menu__b11");
startSubmenu("menu__b7","menu__menu",125);
submenuItem("R/C products","http://www.podman-racing.co.uk/forum/index.php?showforum=5","(none)","menu__plain");
submenuItem("Computer products","http://www.podman-racing.co.uk/forum/index.php?showforum=20","(none)","menu__plain");
endSubmenu("menu__b7");
startSubmenu("menu__b6","menu__menu",98);
submenuItem("Manufacturers","http://www.podman-racing.co.uk/forum/index.php?act=ST&f=13&t=19","(none)","menu__plain" );
submenuItem("Forums","http://www.podman-racing.co.uk/forum/index.php?showtopic=13","(none)","menu__plain");
submenuItem("Tracks","http://www.podman-racing.co.uk/forum/index.php?showtopic=12","(none)","menu__plain");
submenuItem("Shops","http://www.podman-racing.co.uk/forum/index.php?showtopic=11","(none)","menu__plain");
endSubmenu("menu__b6");
startSubmenu("menu__b5","menu__menu",62);
submenuItem("For sale","http://www.podman-racing.co.uk/forum/index.php?showforum=10","(none)","menu__plain");
submenuItem("Wanted","http://www.podman-racing.co.uk/forum/index.php?showforum=11","(none)","menu__plain");
endSubmenu("menu__b5");
startSubmenu("menu__b4","menu__menu",71);
submenuItem("podman","http://www.podman-racing.co.uk/forum/index.php?showtopic=3","(none)","menu__plain");
submenuItem("*Miller*","http://www.podman-racing.co.uk/forum/index.php?showtopic=4","(none)","menu__plain");
submenuItem("SUPERSY","http://www.podman-racing.co.uk/forum/index.php?showtopic=5","(none)","menu__plain");
endSubmenu("menu__b4");
startSubmenu("menu__b3","menu__menu",64);
submenuItem("Outings","http://www.podman-racing.co.uk/forum/index.php?showforum=15","(none)","menu__plain");
submenuItem("Non-R/C","http://www.podman-racing.co.uk/forum/index.php?showforum=16","(none)","menu__plain");
endSubmenu("menu__b3");
startSubmenu("menu__b2","menu__menu",111);
submenuItem("My modifications","http://www.podman-racing.co.uk/forum/index.php?act=ST&f=6&t=16","(none)","menu__plain") ;
submenuItem("GS modifications","http://www.podman-racing.co.uk/forum/index.php?showtopic=9","(none)","menu__plain");
submenuItem("Meet the buggy","http://www.podman-racing.co.uk/galleries/meetthebuggy/index.html","(none)","menu__plain");
submenuItem("Out and about","http://www.podman-racing.co.uk/forum/index.php?act=ST&f=12&t=17","(none)","menu__plain" );
submenuItem("My race results","http://www.podman-racing.co.uk/forum/index.php?showtopic=10","(none)","menu__plain");
endSubmenu("menu__b2");
loc="";
|
XARAmenu.js
Quote:
// ©Xara Ltd 2002
var ma=new Array();var mx=new Array();var my=new Array();var mc=new Array();var mal=0;var main=0;var menuw=200;var psrc=0;var pname="";var al="";var gd=0;var gx,gy;var NS7=(!document.all&&document.getElementById);var NS4=(!document.getElementById);var IE5=(!NS4&&!NS7&&navigator.userAgent.indexOf('MSIE 5.0')!=-1);if(navigator.userAgent.indexOf('Opera')!=-1)NS4=1;var NS6=(NS7&&navigator.userAgent.indexOf('Netscape6') !=-1);function startMainMenu(file,h,w,dir,space,align){if(w>0)men uw=w;main=dir;if(main==1||main==2)document.write(" <table border=\"0\" cellspacing=\""+space+"\" cellpadding=\"0\">");if(file!=""){al="";if(align== 1)al=" align=\"right\"";if(align==2)al=" align=\"center\"";if(main==1||main==2)document.wri te("<tr><td"+al+">");document.write("<img src=\""+loc+file+"\" border=\"0\"");if(h>0)document.write(" height=\""+h+"\"");if(w>0)document.write(" width=\""+w+"\"");document.write(" />");if(main==1||main==2)document.write("</td>");if(main==1)document.write("</tr>");if(main==3)document.write("<br />");}}function endMainMenu(file,h,w){if(file!=""){if(main==1)docu ment.write("<tr>");if(main==1||main==2)document.wr ite("<td"+al+">");document.write("<img src=\""+loc+file+"\" border=\"0\"");if(h>0)document.write(" height=\""+h+"\"");if(w>0)document.write(" width=\""+w+"\"");document.write(" />");if(main==1||main==2)document.write("</td></tr>");}if(main==1||main==2)document.write("</table>");main=0;}function mainMenuItem(name,ext,h,w,url,tar,alt,dir,state,s) {if(NS4&&main==0)return;var isgraphic=ext.charAt(0)==".";if(main==1)document.w rite("<tr>");if(main==1||main==2)document.write("< td"+al+">");document.write("<a ");if(url!=""||!isgraphic)document.write("href=\"" +url+"\" ");if(tar!="")document.write("target=\""+tar+" \" ");document.write("onmouseout=\"");if(dir>0)docume nt.write("tidyMenu(event);");document.write("\" onmouseover=\"");if(dir>0)document.write("openMenu (event, '"+name+"',"+dir+","+bc+","+fc+");");if(state>1&&i sgraphic){document[name+"_over"]=new Image();document[name+"_over"].src=loc+name+"_over"+ext;document.write("setGraph ic(event, '"+loc+name+"_over"+ext+"');");}document.write("re turn false;\"");if(!isgraphic)document.write(" class=\""+s+"\" style=\"width:"+(w>0?w:menuw)+"px\"");document.wri te(">");if(isgraphic){document.write("<img src=\""+loc+name+ext+"\" border=\"0\"");if(h>0)document.write(" height=\""+h+"\"");if(w>0)document.write(" width=\""+w+"\"");if(alt!="")document.write(" alt=\""+alt+"\"");document.write(" />");}else{document.write(" "+ext+" ");}d ocument.write("</a>");if(main==1||main==2)document.write("</td>");if(main==1)document.write("</tr>");if(main==3)document.write("<br />");}function startSubmenu(name,style,sw){if(NS4)return;if(sw>0) menuw=sw;document.write("<div id=\""+name+"\" class=\""+style+"\" style=\"width:"+(menuw+(NS7?bd*2:0))+"px\">");}fun ction endSubmenu(name){if(NS4)return;document.write("</div>");if(!NS7)document.getElementById(name).onmou seout=tidyMenu;}function submenuItem(text,url,tar,s){if(NS4)return;if(text= ="---")document.write("<img src=\""+loc+"---.gif\" height=\"1\" width=\""+menuw+"\" />");else if(text.charAt(0)=='<')document.write(text);else{d ocument.write("<a ");if(url!="")document.write("href=\""+url+"\" ");if(tar!="")document.write("target=\""+tar+" \" ");document.write("class=\""+s+"\" style=\"width:"+menuw+"px\"> "+text+" </a>");}}function setGraphic(event,name){if(NS4)return;psrc=(NS7)?ev ent.target:event.srcElement;pname=psrc.src;if(NS7) event.target.src=name;else event.srcElement.src=name;}function openMenu(event,id,pos,bc,fc){if(NS4)return;var el,x,y;if(gd==0){var p=document.getElementById(id);gx=0;gy=0;while(p&&p .parentNode.nodeName!="BODY"){p=p.parentNode;if(p. nodeName=="DIV"||p.nodeName=="LAYER"||p.nodeName== "SPAN")if(p.style.position=="absolute"){gx+=p.offs etLeft;gy+=p.offsetTop;}}if(p)gd=1;}if(mal>0){el=d ocument.getElementById(ma[mal-1]);if(mx[mal-1]!=el.offsetLeft||my[mal-1]!=el.offsetTop){el.style.left=mx[mal-1];el.style.top=my[mal-1];}tidyMenu(event);}if(NS7){var p=event.target;if(p.nodeName!="A"&&p.nodeName!="IM G"&&p.parentNode.nodeName=="A")p=p.parentNode;dx=p .offsetWidth;dy=p.offsetHeight;if(mal==0){x=p.x;y= p.y;if(typeof(p.x)=="undefined"||!NS6){x=p.offsetL eft;y=p.offsetTop;while(!NS6&&p.parentNode.nodeNam e!="BODY"){p=p.parentNode;if(p.nodeName=="TD"||p.n odeName=="TABLE"){x+=p.offsetLeft;y+=p.offsetTop;} }}}else{el=document.getElementById(ma[mal-1]);x=el.offsetLeft;y=el.offsetTop+p.offsetTop;}if(p os!=3)x-=bd;if(pos==3&&mal>0)x+=bd;}else{x=event.clientX-event.offsetX+document.body.scrollLeft-document.body.clientLeft;y=event.clientY-event.offsetY+document.body.scrollTop-document.body.clientTop;dx=event.srcElement.offset Width;dy=event.srcElement.offsetHeight;if(mal>0){y-=bd;if(pos!=3)x-=2*bd;}x-=gx;y-=gy;}el=document.getElementById(id);if(el&&el.styl e.visibility!="visible"){if(pos==1){x+=dx;el.style .left=x-el.offsetWidth+"px";el.style.top=y+"px";nspeed=el. offsetWidth/frames;}else if(pos==2){y+=dy;el.style.left=x+"px";el.style.top =y-el.offsetHeight+"px";nspeed=el.offsetHeight/frames;}else if(pos==3){x-=el.offsetWidth;el.style.left=x+el.offsetWidth+"px ";el.style.top=y+"px";nspeed=el.offsetWidth/frames;}mx[mal]=x;my[mal]=y;if(NS7||IE5||frames==0){el.style.left=x+"px";el .style.top=y+"px";}if(!IE5)clipMenu(mal,el);el.sty le.visibility="visible";ma[mal]=id;if(NS7){var p=event.target;if(p.nodeName!="A"&&p.parentNode.no deName=="A")p=p.parentNode;mc[mal]=p.style;el.onmouseout=tidyMenu;}else{mc[mal]=event.srcElement.style;if(mal>0){mc[mal].backgroundColor=bc;mc[mal].color=fc;}}mal++;}}function overMenu(x,y){x-=gx;y-=gy;for(i=0;i<mal;i++){var el=document.getElementById(ma[i]);if(el.offsetLeft+el.offsetWidth>x&&el.offsetLeft <=x&&el.offsetTop+el.offsetHeight>y&&el.offsetTop< =y){return ma[i];}}return "";}function tidyMenu(e){if(NS4)return;if(NS7){t=overMenu(e.pag eX,e.pageY);if(t!=""&&(e.target.firstChild==e.rela tedTarget||e.target==e.relatedTarget.firstChild))r eturn;}else t=overMenu(event.clientX+document.body.scrollLeft-document.body.clientLeft,event.clientY+document.bo dy.scrollTop-document.body.clientTop);om=0;for(i=0;i<mal;i++){v ar mail=ma[i].length;if(mail>t.length||t.substring(0,mail)!=ma[i]){var el=document.getElementById(ma[i]);el.style.visibility="hidden";mc[i].backgroundColor="";mc[i].color="";}else{ma[om]=ma[i];mx[om]=mx[i];my[om]=my[i];om++;}}mal=om;if(mal==0&&psrc)psrc.src=pname;}fun ction animate(){for(i=0;i<mal;i++){var el=document.getElementById(ma[i]);if(el.style.visibility=="visible"){if(el.offsetL eft<mx[i])el.style.left=Math.min(el.offsetLeft+nspeed,mx[i])+"px";if(el.offsetLeft>mx[i])el.style.left=Math.max(el.offsetLeft-nspeed,mx[i])+"px";if(el.offsetTop<my[i])el.style.top=Math.min(el.offsetTop+nspeed,my[i])+"px";clipMenu(i,el);}}if(mal!=0||frames!=0)setTi meout("animate()",50);}function clipMenu(i,el){if(el.offsetLeft>mx[i])el.style.clip="rect("+(my[i]-el.offsetTop)+"px "+(el.offsetWidth+(mx[i]-el.offsetLeft))+"px "+el.offsetHeight+"px "+0+"px)";else el.style.clip="rect("+(my[i]-el.offsetTop)+"px "+el.offsetWidth+"px "+el.offsetHeight+"px "+(mx[i]-el.offsetLeft)+"px)";}
|
|

08-20-03, 06:21 PM
|
 |
Coding Addict
|
|
Join Date: May 2003
Location: Virginia
Posts: 391
Thanks: 0
Thanked 8 Times in 3 Posts
|
|
Moved to appropriate forum.
|

08-21-03, 01:49 PM
|
|
New Member
|
|
Join Date: Aug 2003
Location: Hampshire, UK
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank-you for moving my post, very sorry.
Ive sorted it out now I removed "none" in the Menu_.js file, to leave just the two ""s
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|