Click to See Complete Forum and Search --> : Pop-Up JS


mackiller
12-20-2002, 07:55 PM
I have a site that is being used for humor only and I was wondering if there was a way to make a certain page load into a window that would pop up a certain # of times?

Beach Bum
12-20-2002, 08:36 PM
could you be more specific.

do you want the page to keep poping up when the person closes the current page? try the onunload event (goes in the body statement).

do you want to have a new window just pop up a bunch of times while they are looking at a page? try using seTimeout to rerun the function after a second or two with a counter to stop it after a certain number of times.

or do you want something else?

we can give you more specific coding advice if you narrow down what you are after.

gil davis
12-20-2002, 09:24 PM
I fail to find any humor in pop-up windows.

Beach Bum
12-20-2002, 09:56 PM
I fail to find any humor in pop-up windows.
i would agree with you - but the humor i find in pop-up windows is that "they" assume we see them (i use pop-up stopper).

mackiller
12-21-2002, 05:20 PM
Ok, here are the details:
When the page loads, I want a window to pop up. I want this window to pop up x times and I would like this window to keep popping up if they leave this site.

As for the humor part, it is a site making fun of the stupidity of pop ups!

Beach Bum
12-21-2002, 05:50 PM
then you may want to use onload="popIt()" in your body statement. Where popIt is a javascript function that uses window.open to pop up a window. in window.open you can specify the size you want. then you could use a loop/counter in the function to execute the window.open how ever many times you want.

reread what you said - you want it to keep poping even after they leave the site. then forget the loop/counter.

in the new window you open with window.open you would need to put another onload with another window.open - that way as each window loads it loads another. until it opens a window without another window.open

mackiller
12-21-2002, 10:28 PM
ok, thanks! I am quite new to JS, so can you show me what the code would look like?

Beach Bum
12-21-2002, 10:49 PM
don't have any examples as i would never use a pop-up window.

but i think the syntax is:

<script type="text/javascript">
function popIt() {
window.open("nextwindow.htm","name","width=xx,height=xx");
}
</script>

put that in the head of your html

then in the body statement:

<body onload="popIt()">