mortalc Posted May 13, 2010 Share Posted May 13, 2010 1. How can I get a popup box to appear as soon as the site is opened?2. How can I get a popup box to appear after the last popup box has been 'ok'd?And now an unrelated question while I'm here:3. Are the only conditions for a while loop variables? or are there others? Link to comment Share on other sites More sharing options...
ShadowMage Posted May 13, 2010 Share Posted May 13, 2010 1. How can I get a popup box to appear as soon as the site is opened?2. How can I get a popup box to appear after the last popup box has been 'ok'd?And now an unrelated question while I'm here:3. Are the only conditions for a while loop variables? or are there others?1. window.onload2. There are a variety of ways, for example in a function you call from an onclick event of a close button on the last popup.3. You can put any conditional statement you want to in a while loop as long as it can be evaluated to true or false:while (testCondition()) { //do something}...function testCondition() { //code here return true; //or return false; or return a variable to evaluate} Link to comment Share on other sites More sharing options...
mortalc Posted May 13, 2010 Author Share Posted May 13, 2010 1. window.onload2. There are a variety of ways, for example in a function you call from an onclick event of a close button on the last popup.3. You can put any conditional statement you want to in a while loop as long as it can be evaluated to true or false:while (testCondition()) { //do something}...function testCondition() { //code here return true; //or return false; or return a variable to evaluate} 1. Where would I put window.onload in the code?2. Could you give me an example/tell me how to do it? Link to comment Share on other sites More sharing options...
ShadowMage Posted May 13, 2010 Share Posted May 13, 2010 1. Where would I put window.onload in the code?2. Could you give me an example/tell me how to do it?You would put the window.onload directly in your <script> tags:<html><head><script type='text/javascript'>window.onload = function() { //do some stuff}//Rest of your code and functions</script></head> You want an example of the popups? That depends on what kind of popup you want. There are a couple different ways:1. A new window popup2. An HTML popup with <div> tags Link to comment Share on other sites More sharing options...
mortalc Posted May 13, 2010 Author Share Posted May 13, 2010 You would put the window.onload directly in your <script> tags:<html><head><script type='text/javascript'>window.onload = function() { //do some stuff}//Rest of your code and functions</script></head> You want an example of the popups? That depends on what kind of popup you want. There are a couple different ways:1. A new window popup2. An HTML popup with <div> tags I meant an example of to call from an onclick event of a close button on the last popup. (your answer to number 2)...The type of popup box I'm aiming for is an Alert Box. Link to comment Share on other sites More sharing options...
ShadowMage Posted May 13, 2010 Share Posted May 13, 2010 I meant an example of to call from an onclick event of a close button on the last popup. (your answer to number 2)...The type of popup box I'm aiming for is an Alert Box.Oh, sorry my bad. I'm assuming you want a confirm dialog (OK and Cancel buttons) and you only want to show popup #2 if user clicks OK in popup #1 then right?In that case you'd use the confirm() method and forget about the onclick event. Everything will go in the window.onload event:window.onload = function() { var result = window.confirm("Is this what you want?"); if (result) { window.alert("You OK'd this message"); }} Link to comment Share on other sites More sharing options...
mortalc Posted May 13, 2010 Author Share Posted May 13, 2010 Thankyou!I was just wondering...Would it be possible to put the "if" bit inside a loop? Plus a bit more, of course. Link to comment Share on other sites More sharing options...
ShadowMage Posted May 13, 2010 Share Posted May 13, 2010 Thankyou!I was just wondering...Would it be possible to put the "if" bit inside a loop? Plus a bit more, of course.Of course it is. What kind of loop? More specifically what are you trying to do? Link to comment Share on other sites More sharing options...
mortalc Posted May 13, 2010 Author Share Posted May 13, 2010 A while loop.Er... ... Because of your fantastic help, I think I know what I'm doing. Except for one thing... The example you gave me is a confirmation followed by an alert. How would I do an alert followed by an alert? Link to comment Share on other sites More sharing options...
ShadowMage Posted May 13, 2010 Share Posted May 13, 2010 A while loop.Er... ... how about this... Because of your fantastic help, I think I know what I'm doing. Except for one thing... The example you gave me is a confirmation followed by an alert. How would I do an alert followed by an alert?Alerts are simple to do consecutively. Just put them one right after another. The next one won't popup until OK is clicked on the first.window.alert("alert message one");window.alert("alert message two");Sorry, I was confused again. The way you worded this: "How can I get a popup box to appear after the last popup box has been 'ok'd?" sounded like you wanted to get the users permission. But it sounds like all you need is a succession of alerts just telling the user something and not giving the user any options.Edit:You could even do that in a loop:var x=0;while (x<5) { alert("This is message #"+x); x++;} Link to comment Share on other sites More sharing options...
mortalc Posted May 13, 2010 Author Share Posted May 13, 2010 So simple!Thankyou! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.