Forum Moderators: open

Message Too Old, No Replies

Call a javascript from within a javascript menu.

Want a popup window generated by menu click

         

bab01824

5:48 pm on Jul 29, 2004 (gmt 0)



I have a javascript that writes my menu bar on each page. Instead of a standard <a href=...>, I would like to call another javascript that pops up a window without toolbar, scrollbar, etc.

Here's part of the menu.js scrip that I'm using;
<code>
document.write('<DIV id="menulocation">');
document.write('<TABLE cellpadding="0" cellspacing="0" border="0" width="100%" background="picts/background-menu.gif" bgcolor="#C0C0C0"><tr><td>');
document.write('<TABLE cellpadding="0" cellspacing="0" border="0"><tr><td width="25">&nbsp;<br>');

// START LINKS //

document.write('</td><td nowrap>');
document.write('<a href="index.html" class="menu">Home</a>');

document.write('</td><td nowrap>');
document.write('<a href="about.htm" class="menu">Company</a>');

document.write('</td><td nowrap>');
document.write('<a href="services.htm" class="menu">Services</a>');
</>
and so on...

Here's the script (searchinventory.js) that pops up the window I want.
<code>

var popurls=new Array()
popurls[0]="search.htm"

function openpopup(popurl){
var winpops=window.open(popurl,"","width=800,height=600")
}

openpopup(popurls[Math.floor(Math.random()*(popurls.length))])
</>

The array is so I can pop up a series of URLS, but that's not important because right now I want the same URL all the time.

What do I put into the menu.js to call searchinventory.js?

Bruce B

StupidScript

11:13 pm on Jul 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<menu.js>

document.write('<a href="javascript:openpopup(0)" class="menu">Search</a>');
document.write('<a href="javascript:openpopup(1)" class="menu">Services</a>');

<searchinventory.js>

var popurls=new Array()
popurls[0]="search.htm" ;
popurls[1]="services.htm";

function openpopup(idx){
var winpops=window.open(popurls[idx],"","width=800,height=600");
}