...

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



effectivesite
09-10-2011, 08: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:

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

-----------------------------------------
<SCRIPT LANGUAGE="JavaScript">
<!-- 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",
"width=450,height=455,scrollbars=yes,menubar=no");
expire=new Date(expire.getTime()+7776000000);
document.cookie="COOKIE1=here; expires="+expire;
}
// -->
</SCRIPT>
-----------------------------------------


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?

xelawho
09-10-2011, 09: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");
}
</script>

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

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

xelawho
09-10-2011, 11:02 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum