?
Solved

Javascript sidemenu open new window??

Posted on 2004-11-28
10
Medium Priority
?
312 Views
Last Modified: 2012-06-21
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();
0
Comment
Question by:mdmcq5
  • 5
  • 3
  • 2
10 Comments
 
LVL 25

Expert Comment

by:archrajan
ID: 12691039
can u post more code related to this
0
 
LVL 25

Expert Comment

by:archrajan
ID: 12691056
0
 
LVL 25

Expert Comment

by:devic
ID: 12691057
probably you forgot return false;
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 25

Expert Comment

by:devic
ID: 12691112
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>
0
 

Author Comment

by:mdmcq5
ID: 12691116
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>
0
 
LVL 25

Accepted Solution

by:
devic earned 2000 total points
ID: 12691212
very careful replace  this:
=========================
"http://mywebpage.com"

with this:
=========================
"javascript:void(window.open(\"http://mywebpage.com\"))"
0
 

Author Comment

by:mdmcq5
ID: 12691276
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.....
0
 
LVL 25

Expert Comment

by:devic
ID: 12691308
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.
0
 

Author Comment

by:mdmcq5
ID: 12691332
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();
0
 
LVL 25

Expert Comment

by:devic
ID: 12691346
for this reason I wrote very careful :)

you are welcome!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question