Jump to content

How do i program popups


washingtonirvine

Recommended Posts

Im trying to learn more on popup writting in js, i want more than one popup to open on when a page is launched. im just fooling around with notepad pratice sites at the moment and working with this codeSCRIPT LANGUAGE="JavaScript">function popUp(URL) {day = new Date();id = day.getTime();eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=300,height=300,left = 533,top = 234');");}</script><BODY onLoad="java script:popUp('http://www.google.com')">how do i adjust this code to add another popup when page is loaded?

Link to comment
Share on other sites

how do i adjust this code to add another popup when page is loaded?
Add another function that calls the popUP() function with a list of URLs. Change this:
<BODY onLoad="java script:popUp('http://www.google.com')">

To something like this:

<BODY onLoad="java script:popLaunch()">

The popLaunch() function would contain a list of URLs which would call the popUp() function:

function popLaunch(){popUp('http://www.google.com')"popUp('http://www.w3schools.com')"}

Link to comment
Share on other sites

FWIW, I would ditch the eval() and set up your page variable as an array:

function popUp(URL) {   day = new Date();   id = day.getTime();   page = new Array();   var tmpWin = window.open(URL, id, 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=300,height=300,left = 533,top = 234');   page.push(tmpWin);}

Other than that, End User hit the nail on the head in regards to creating several popups.

Link to comment
Share on other sites

Is that everything in your <script> tags? You still need to have the function you made. The body should be outside the <script> and the <head>. You also have an error (typo?) when you call the popUp function. You need to end the line with a ';' not ".popUp('http://www.google.com');popUp('http://www.w3schools.com');FWIW, you shouldn't really use the language attribute anymore. Use the type attribute instead:<script type='text/javascript'>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...