Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

myMenu2.addMenuItem("Click Me", "location='http://file.html'&quot

Status
Not open for further replies.

oliverreade

Programmer
Mar 12, 2002
10
0
0
GB
I have got this small JavaScript menu and have used it.

One of my screens calls this pop-up menu many times each time with a different menu.

The only problem I am having is that I don't know how to open any of the links in another window!

Everyone has advised me to use : window.open()

The line of code I am having difficulty with is :

myMenu2.addMenuItem("Click Me", "location='
As I have mentioned to them where would window.open go esp. since I am not using the href tag?


Any help would be gratefully appreciated.


Thanx
 
do you want them all to open in a new window? perhaps you could set target="_blank".

Seeing the actual script would help a lot too.
 
I have tried what you have mentioned but it still doesn't work!

Here is the code anyway:

<HTML>
<HEAD>
<SCRIPT src=menu.js language=JavaScript></SCRIPT>
</HEAD>
<body bgcolor=&quot;#C0C0C0&quot; text=&quot;#000000&quot;>
<SCRIPT Language=&quot;Javascript&quot;>
//Create Menu 1
window.myMenu1 = new Menu(&quot;Technologies&quot;);
myMenu1.addMenuItem(&quot;item1 from menu1&quot;, &quot;location='G:/html/hello1.html'&quot;);
//--- Create Menu 2
window.myMenu2 = new Menu();
myMenu2.addMenuItem(&quot;item1 from menu2&quot;, &quot;location='G:/html/hello2.html'&quot;);
//--Write out menus suing call to first mwnu created
myMenu1.writeMenus();
</SCRIPT>

<center>
<table width=700 border=0 >
<tr> <td>
<font face=&quot;Geneva, Arial, Helvetica, san-serif&quot;>
<A HREF=&quot;javascript://&quot; onClick=&quot;showMenu(window.myMenu1);&quot;>
<b>menu1</b></font></a>
</td><td>
<center>
<font face=&quot;Geneva, Arial, Helvetica, san-serif&quot;>
<A HREF=&quot;javascript://&quot; onClick=&quot;showMenu(window.myMenu2);&quot;>
<b>menu2</b></font></a>
</center></td></tr>
</table>
</CENTER>
</BODY>
</HTML>
 
I have tried what you have mentioned but it still doesn't work!

Here is the code anyway:

<HTML>
<HEAD>
<SCRIPT src=menu.js language=JavaScript></SCRIPT>
</HEAD>
<body bgcolor=&quot;#C0C0C0&quot; text=&quot;#000000&quot;>
<SCRIPT Language=&quot;Javascript&quot;>
//Create Menu 1
window.myMenu1 = new Menu(&quot;Technologies&quot;);
myMenu1.addMenuItem(&quot;item1 from menu1&quot;, &quot;location='G:/html/hello1.html'&quot;);
//--- Create Menu 2
window.myMenu2 = new Menu();
myMenu2.addMenuItem(&quot;item1 from menu2&quot;, &quot;location='G:/html/hello2.html'&quot;);
//--Write out menus suing call to first mwnu created
myMenu1.writeMenus();
</SCRIPT>

<center>
<table width=700 border=0 >
<tr> <td>
<font face=&quot;Geneva, Arial, Helvetica, san-serif&quot;>
<A HREF=&quot;javascript://&quot; onClick=&quot;showMenu(window.myMenu1);&quot;>
<b>menu1</b></font></a>
</td><td>
<center>
<font face=&quot;Geneva, Arial, Helvetica, san-serif&quot;>
<A HREF=&quot;javascript://&quot; onClick=&quot;showMenu(window.myMenu2);&quot;>
<b>menu2</b></font></a>
</center></td></tr>
</table>
</CENTER>
</BODY>
</HTML>

Thanx
 
Ah - you're using an include &quot;menu.js&quot;...I'll need to see the function &quot;showMenu()&quot; in it to see how it's handling the redirects.

My guess is it's similar to this:
Code:
function showMenu(menuItem) {
  window.location.href = menuItem.URL;
}

If this is the case, and you want all menu links to open in new windows, you'd need to modify it like such:
Code:
function showMenu(menuItem) {
  theURL = menuItem.URL;

  // give the window a name in case you want to target links to it...
  strName = &quot;newWindowName&quot;;
  // add whatever window settings you want...
  strParams = &quot;height=500,width=400&quot;;
  // make the new window
  newWindow = window.open(theURL,strTitle,strParams);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top