Forum Moderators: open

Message Too Old, No Replies

Need a one time pop up per visit

         

D_Blackwell

4:20 am on Mar 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need a pop up that will only pop once. Visitors stay awhile and move around the site, and may even hit the home page several times. I need a cross browser JS that will only pop once per visit, and not everytime they hit the page. I know enough JS to manipulate a script that works, but can't write one. Sources?

luckydude

5:01 am on Mar 8, 2004 (gmt 0)

10+ Year Member



how do you want your window to pop up? Do you want it to pop up on body load, or when someone clicks on something, or someone moves mouseover certain objects. However you want your little window to pop up, just call the function (in this case, the function is pop_up(), it will do it. Here is the basic code for it.


<head>
<script language="javascript">
<!--
function pop_up()
{
window.open("something.htm","name","width=200,height=200");
}
//-->
</script>
</head>
<body>
<input type="button" value="New Window" onClick="pop_up();">
</body>

you can add more stuff there, such as: location of the window, menubar, resizable, scrollbars, status, toolbar and so on. To set the attributes (only that are Booleans), you can assign them a value of "yes" or "no". You may also use "1 for yes" and "0 for no". Similarly, you can also define where you want your little window to pop up: such and such pixels from left and top.


screenX=100px,left=100px,screenY=100,top=100px

Note that screenX and screenY only work on NS and left and top only work on IE. Since you are trying to create a pop up window that works on both browsers, you might want to include both. Each browser will just ignore the attributes that it doesn't recognize.

I hope this helps. Let us know if you need any help.

Luckydude

Purple Martin

5:31 am on Mar 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use a server-side session variable. If it's false, output the code to do an onLoad popup and then set the session variable to true. If it's true, don't write the output code.