Who Dat
asked on
Javascript sidemenu open new window??
I'm writing code to have a sidemenu on a webpage. The problem I am having is if I try to add code to have certain links open in a new window, I receive error messages. I'm not certain how to add additional code to my coding below with no errors. Please help. Thanks.
addmenu(menu=["subMenu3815 4",,,170,, ,style2,0, "left",eff ect,,0,,,, ,,,"",,,," <div style='padding : 1 5;'>(GGI) </div>","http://mywebpage.com","",,1,"<div style='padding : 1 5;'>ORTHO</div>","http://mywebpage.com","",,1, "<div style='padding : 1 5;'>USACE</div>","http://mywebpage.com","",,1, "<div style='padding : 1 5;'>Demo Tracker</div>","http://mywebpage.com","",,1]); addmenu(me nu=["sidem enu",150,0 ,158,,,sty leside,1," left",effe ct,,0,,,,, ,,"",,,,"< div style='padding : 1 5'><strong>Resources</stro ng></div>" ,"http://mywebpage.com","",,1, "<div style='padding : 1 5;'>Downloads</div>","http://mywebpage.com","" ,,1,"<div style='padding : 1 5;'>Links</div>","http://mywebpage.com","",,1, "<div style='padding : 1 5'>Tracker</div>","show-me nu=subMenu 38154","http://mywebpage.com", ,1]);
dumpmenus();
addmenu(menu=["subMenu3815
dumpmenus();
can u post more code related to this
http://www.dynamicdrive.com/dynamicindex1/slideinmenu.htm see this for more info
probably you forgot return false;
e.g.:
<a href="javascript:window.op en('http://www.google.com')">err or</a>
<a href="javascript:void(wind ow.open('http://www.google.com') );">no error</a>
<a href="javascript:window.op
<a href="javascript:void(wind
ASKER
That's pretty much all of the code for the sidemenu.
The code works perfectly as it is, but a few of the links I would like to open in a new window. There is absolutely nothing wrong with the way the code is written. I just want to know whether there is a way to allow for a new window to open to be added to the way the coding is currently written. I do not want to reformat my coding b/c it's on about 45 other pages. It's just this one particular sidemenu for one page I'm developing that I'd like to open the links in a new window.
If I add additional code to do this, like w/ "[]";, etc. it errors out. And I have not forgotten any coding, such as return false;
Any ideas??
<SCRIPT type="text/javascript">
addmenu(menu=["subMenu3815 4",,,170,, ,style2,0, "left",eff ect,,0,,,, ,,,"",,,," <div style='padding : 1 5;'>(GGI) </div>","http://mywebpage.com","",,1,"<div style='padding : 1 5;'>ORTHO</div>","http://mywebpage.com","",,1, "<div style='padding : 1 5;'>USACE</div>","http://mywebpage.com","",,1, "<div style='padding : 1 5;'>Demo Tracker</div>","http://mywebpage.com","",,1]); addmenu(me nu=["sidem enu",150,0 ,158,,,sty leside,1," left",effe ct,,0,,,,, ,,"",,,,"< div style='padding : 1 5'><strong>Resources</stro ng></div>" ,"http://mywebpage.com","",,1, "<div style='padding : 1 5;'>Downloads</div>","http://mywebpage.com","" ,,1,"<div style='padding : 1 5;'>Links</div>","http://mywebpage.com","",,1, "<div style='padding : 1 5'>Tracker</div>","show-me nu=subMenu 38154","http://mywebpage.com", ,1]);
dumpmenus();
</SCRIPT>
<tr class="noBorder" ><td id="sideBarCell" valign="top" width="158" class="noBorder">
<script type="text/javascript" language="Javascript1.1">
tblHeight=0;
theName="menu"+getMenuByNa me("sideme nu");
var domObj;
if(ns4){
domObj = document[theName];
if(domObj != null){
PlaceMenu("sidemenu");
tblHeight=domObj.clip.heig ht-18;//th e 18 is due to some odd padding that is showing up on the screen.
document.write("<span height=" + (tblHeight+2) + "><img src=\"../images/spacer.gif \" height=1></span>");
}
}
else{
domObj = document.getElementById(th eName);
if(domObj != null){
PlaceMenu("sidemenu");
tblHeight=domObj.offsetHei ght;
document.getElementById("s ideBarCell ").height= tblHeight;
}
}
</script>
The code works perfectly as it is, but a few of the links I would like to open in a new window. There is absolutely nothing wrong with the way the code is written. I just want to know whether there is a way to allow for a new window to open to be added to the way the coding is currently written. I do not want to reformat my coding b/c it's on about 45 other pages. It's just this one particular sidemenu for one page I'm developing that I'd like to open the links in a new window.
If I add additional code to do this, like w/ "[]";, etc. it errors out. And I have not forgotten any coding, such as return false;
Any ideas??
<SCRIPT type="text/javascript">
addmenu(menu=["subMenu3815
dumpmenus();
</SCRIPT>
<tr class="noBorder" ><td id="sideBarCell" valign="top" width="158" class="noBorder">
<script type="text/javascript" language="Javascript1.1">
tblHeight=0;
theName="menu"+getMenuByNa
var domObj;
if(ns4){
domObj = document[theName];
if(domObj != null){
PlaceMenu("sidemenu");
tblHeight=domObj.clip.heig
document.write("<span height=" + (tblHeight+2) + "><img src=\"../images/spacer.gif
}
}
else{
domObj = document.getElementById(th
if(domObj != null){
PlaceMenu("sidemenu");
tblHeight=domObj.offsetHei
document.getElementById("s
}
}
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If I add "javascript:void(window.op en(\"http://mywebpage.com\"))"
it still doesn't work.
The code is accepted, but when run and the url is clicked, an error appears that says "error on page".
If I use "(window.open(\"http://mywebpage.com\"))" it opens to an empty page, not the specified url.
If I use "window.open(\"http://mywebpage.com\")" it too opens to an empty page, not the specified url & same for "window.open(\"http://mywebpage.com\"))"
if i do this: ("http://mywebpage.com")" it says it can't find the page, it's using the folder the main page is placed in. So, it's saying it can't find the file... resources\tracker\http.... .
it still doesn't work.
The code is accepted, but when run and the url is clicked, an error appears that says "error on page".
If I use "(window.open(\"http://mywebpage.com\"))" it opens to an empty page, not the specified url.
If I use "window.open(\"http://mywebpage.com\")" it too opens to an empty page, not the specified url & same for "window.open(\"http://mywebpage.com\"))"
if i do this: ("http://mywebpage.com")" it says it can't find the page, it's using the folder the main page is placed in. So, it's saying it can't find the file... resources\tracker\http....
http://home.arcor.de/athens/expexc/js/menu/
I uploaded example online:
if you go to "Plain Magic Software"
there you will see "SEMBEL.NET" click it.
I uploaded example online:
if you go to "Plain Magic Software"
there you will see "SEMBEL.NET" click it.
ASKER
IT WORKS!
Sorry, devic..
I must have accidentally erased the , after the "
thanks for your help!.
addmenu(menu=["subMenu3815 4",,,170,, ,style2,0, "left",eff ect,,0,,,, ,,,"",,,," <div style='padding : 1 5;'>(GGI) </div>","javascript:void(w indow.open (\"http://mywebpage.com\"))","" ,,1,"<div style='padding : 1 5;'>ORTHO</div>","http://mywebpage.com","",,1, "<div style='padding : 1 5;'>USACE</div>","http://mywebpage.com","",,1, "<div style='padding : 1 5;'>Demo Tracker</div>","http://mywebpage.com","",,1]); addmenu(me nu=["sidem enu",150,0 ,158,,,sty leside,1," left",effe ct,,0,,,,, ,,"",,,,"< div style='padding : 1 5'><strong>Resources</stro ng></div>" ,"http://mywebpage.com","",,1, "<div style='padding : 1 5;'>Downloads</div>","http://mywebpage.com","" ,,1,"<div style='padding : 1 5;'>Links</div>","http://mywebpage.com","",,1, "<div style='padding : 1 5'>Tracker</div>","show-me nu=subMenu 38154","http://mywebpage.com", ,1]);
dumpmenus();
Sorry, devic..
I must have accidentally erased the , after the "
thanks for your help!.
addmenu(menu=["subMenu3815
dumpmenus();
for this reason I wrote very careful :)
you are welcome!
you are welcome!