View Full Version : 2 sites to have pop-up on entry, then not show again

09-10-2011, 09:33 PM
I'm making 2 sites and need a visitor who lands on the home page of either site to first be shown a page that shows a company introduction and 2 links at the bottom so they can choose which division of the site (which website) they want to go to.

Does anyone know of any pre-made java or other code that would allow for this? So that a visitor doesn't get stuck in a cycle of being taken from one home page to the other and having the pop-up every time, I'm thinking it will likely need to write a cookie saying they've seen the pop up, then it won't appear again.
Each site would then have to check for a cookie from either site.

Does anyone have any ideas on how to make this work? I'm open to anything and have to have it done by friday :eek:

09-10-2011, 09:40 PM
I believe I've found the solution.
the code is

<!-- Script courtesy of Web Page Design | Website Design | Website Designing | Web Site Design | Web Site Designing | Web Page Development | Web Development - Your Guide to Professional Web Site Design and Development
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("yourpagename.html", "dispwin",
expire=new Date(expire.getTime()+7776000000);
document.cookie="COOKIE1=here; expires="+expire;
// -->

The only thing I'm not sure of is how would I get it to check for a cookie from either of the 2 sites?
anyone know?

09-10-2011, 10:04 PM
you don't really need to use cookies (and people disable them anyway) - you can do this very simply using query strings in the links on the page. maybe this will help:

<script type="text/javascript">
var intro = self.location.search;
if (intro=="?refer"){
alert("you don't need to see the intro");
} else {
alert("here's the intro");

<a href="page2.htm?refer" target="_self">go to page 2</a>

09-10-2011, 11:45 PM
that's perfect thanks!
Hadn't thought of doing that, definitely the simplest method though.
thank you very much.

09-11-2011, 12:02 AM
you're welcome.

I realised, though, looking back on it that the first two lines could be simplified into:
if (self.location.search=="?refer"){

if you're into that sort of thing.