Welcome to WebmasterWorld Guest from 184.73.3.107

Forum Moderators: brotherhood of lan & mack

javascript - popup windows

multiple popups on one page

   
7:23 pm on Mar 3, 2003 (gmt 0)

10+ Year Member



I know very little about javascript, but really 'need' to use popup windows on a site I'm designing to save space. I copied some code from a jscript tutorial site, and it worked fine when there was only one pop up on the page. But now that I've created several popups for the page, only one of them gets displayed for all the buttons on the page.

I think there is a variable that is being set in the loadwindow function that is affecting this, but don't know much beyond that.

here's what the code snippet looks like:

<script>
function loadwindow(){
window.open("Pop_up1.html","","width=400,height=350,status=1")
}
</script>
<form><input type="button" onClick="loadwindow()" value="See Description"></form>

<<new row, cell, etc.>>

<script>
function loadwindow(){
window.open("Pop_up2.html","","width=400,height=350,status=1")
}
</script>
<form><input type="button" onClick="loadwindow()" value="See Description"></form>

The problem is that its loading Pop_up2.html for both buttons.

I know I need to actually learn this stuff and I'm trying the easy way out, but just this once please help! :)

7:30 pm on Mar 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi lachtzu,

in your code, the main mistake is to define the function loadwindow() two times. if you locate the second definition of the function, just add a '2' to the functions name (it will then be loadwindow2()), and do so in the second button which then will open the 2nd popup window.

7:32 pm on Mar 3, 2003 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



maybe pass the pagename to the function

function loadwindow(page){
window.open(page,"popup","width=400,height=350,status=1")
}

<input type="button" onClick="loadwindow('Pop_up1.html')" value="See Description">
<input type="button" onClick="loadwindow('Pop_up2.html')" value="See Description">

8:04 pm on Mar 3, 2003 (gmt 0)

10+ Year Member



and the winner is...Hakre! I'm sure both work - in this case naming the functions separately was very easy and quick. Thanks
 

Featured Threads

Hot Threads This Week

Hot Threads This Month