Click to See Complete Forum and Search --> : Problem
Problem: I would like to use a script that makes users go through my index.htm first. This is easy to do if index.htm has an href link to another page in it. However, my index.htm has an image that uses the onClick="window.open()" function instead of a plain old href link. Any ideas how i could still do this, assuming it can be done?
Thanks in advance,
TJL
gil davis
08-24-2003, 07:44 AM
You could look for a script that relies on a cookie to authenticate that the user has seen your index page.
You could also change the referrer script to look for "opener" as well as "referrer".
window.opener.location.hrefwould contain the URL of the index page.
I like the idea of using a cookie to check to see if a guest has come through my index.htm. Does anyone know how to do this? I have very little experience with javascripts.
TJL
Jupac
08-24-2003, 09:49 PM
This??maybe
<script type=text/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 getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name,value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function index(){
var to=1;
var expdate = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 31));
if (to==1) {
SetCookie ("ok",1,expdate);
window.history.go(0);
}
}
if (GetCookie ("ok")==0){alert("please go in by my index")
}
}
</script>
use <body onload=index()>
i might have messed up in a hurry sorry?? be bck shortyly