Link to home
Start Free TrialLog in
Avatar of Who Dat
Who DatFlag for United States of America

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=["subMenu38154",,,170,,,style2,0,"left",effect,,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(menu=["sidemenu",150,0,158,,,styleside,1,"left",effect,,0,,,,,,,"",,,,"<div style='padding : 1 5'><strong>Resources</strong></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-menu=subMenu38154","http://mywebpage.com",,1]);

dumpmenus();
Avatar of archrajan
archrajan

can u post more code related to this
Avatar of devic
probably you forgot return false;
e.g.:
<a href="javascript:window.open('http://www.google.com')">error</a>
<a href="javascript:void(window.open('http://www.google.com'));">no error</a>
Avatar of Who Dat

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=["subMenu38154",,,170,,,style2,0,"left",effect,,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(menu=["sidemenu",150,0,158,,,styleside,1,"left",effect,,0,,,,,,,"",,,,"<div style='padding : 1 5'><strong>Resources</strong></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-menu=subMenu38154","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"+getMenuByName("sidemenu");
      var domObj;
      if(ns4){
        domObj = document[theName];
        if(domObj != null){
          PlaceMenu("sidemenu");
          tblHeight=domObj.clip.height-18;//the 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(theName);
        if(domObj != null){
          PlaceMenu("sidemenu");
          tblHeight=domObj.offsetHeight;
          document.getElementById("sideBarCell").height=tblHeight;
        }
      }

    </script>
ASKER CERTIFIED SOLUTION
Avatar of devic
devic
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Who Dat

ASKER

If I add "javascript:void(window.open(\"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.....
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.
Avatar of Who Dat

ASKER

IT WORKS!

Sorry, devic..
I must have accidentally erased the , after the "

thanks for your help!.

addmenu(menu=["subMenu38154",,,170,,,style2,0,"left",effect,,0,,,,,,,"",,,,"<div style='padding : 1 5;'>(GGI) </div>","javascript:void(window.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(menu=["sidemenu",150,0,158,,,styleside,1,"left",effect,,0,,,,,,,"",,,,"<div style='padding : 1 5'><strong>Resources</strong></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-menu=subMenu38154","http://mywebpage.com",,1]);

dumpmenus();
for this reason I wrote very careful :)

you are welcome!