|
How can I make a window open up automatically the first time a visitor stops by a page?
Can I reset it so that repeat visitors will see the window if I update the information in the window?
Here is a small JavaScript that will allow you to greet first time visitors to your site with a pop-up window. If you ever need to update the information contained in popwin.html, simply rename the cookie. As an example, in the code below, it is called COOKIE1. To make it so that nobody has ever been to your site before, change both occurrences of COOKIE1 to COOKIE2 and so on...
Be certain when copying the code to keep the very long line below intact. You will get an error if you split the line. Have some fun; play with the various options such as height, width, and scrollbars!
Insert the code below under <title>Your Site Name</title> in your page:
<SCRIPT LANGUAGE="JavaScript"> <!-- function GetCookie(name) { var arg=name+"="; var alen=arg.length; var clen=document.cookie.length; var i=0; while (i<clen) { var j=i+alen; if (document.cookie.substring(i,j)==arg) return "here"; i=document.cookie.indexOf(" ",i)+1; if (i==0) break; } return null; } var visit=GetCookie("COOKIE1"); if (visit==null){ var expire=new Date(); window.name = "thiswin"; newwin=open("popwin.html", "dispwin", "width=250,height=300,scrollbars=no,menubar=no"); document.cookie="COOKIE1=here; expires=Thu 01-01-2004 00:00:00 GMT;"; } // --> </SCRIPT>
Author: Disabled Cops
This FAQ has been read 3243 times.
Print the Page Script
Print out the page's last update date.
Multiple Submit Buttons
Make your Web Page the Clients Home Page
JavaScript Hello
Is there a way I can have my page automatically remove itself from a frame controlled by another site?
How do I create a "back" button or link on my site?
How can I make a window open up automatically the first time a visitor stops by a page?
|