Jump to content
Sign in to follow this  
washingtonirvine

How do i program popups

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?

Share this post


Link to post
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')"}

Share this post


Link to post
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.

Edited by ShadowMage

Share this post


Link to post
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'>

Edited by ShadowMage

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...