
April 4th, 2004, 12:16 AM
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Script works in IE but not NS... How can I fix this?
URL Posted: Sat Apr 03, 2004 9:24 am Post subject: Script works in IE but not NS... How can I fix this?URL I have this little script that redirects a visitor to my disclaimer page when they first enter my site. the visitor finds my site from an outside link or a search engine. They click a link that would open 'desiredPage.htm'. a cookie check script on 'desiredPage.htm' senses that the cookie 'disclaimer=viewed' is null and redirects to 'disclaimer.htm'. Upon accepting the terms of the disclaimer, the cookie 'disclaimer=viewed' is set and the visitor is send back one in their history to 'desiredPage.htm'. Of course 'desiredPage.htm' checks for the cookie again but, this time it is there and normal browsing of the site is allowed. This works perfectly in IE but in NS, the initial redirect happens so quickly that 'desiredPage.htm' is never registered in the history. As a result, after accepting the terms of 'disclaimer.htm', visitors are taken back out of the site. Can someone PLEASE tell me how to correct this for NS. Please bear in mind, that this is my first ever attempt a Javascript and cookies so please be kind.
'desiredPage.htm'
Code:
<head>
<script LANGUAGE="JavaScript1.1">
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1) {
endstr = document.cookie.length;
}
return unescape(document.cookie.substring(offset, endstr));
}
function getCookie (cookieName) {
var arg = cookieName + "=";
var argLength = arg.length;
var cookieLength = document.cookie.length;
var i = 0;
while (i < cookieLength) {
var j = i + argLength;
if (document.cookie.substring(i, j) == arg) {
return getCookieVal(j)
}
if (i == 0) {
break
}
}
return null;
}
if(getCookie('disclaimer') == null) {
location.href="disclaimer.htm"
}
// End -->
</script>
'disclaimer.htm'
Code:
<head>
<script LANGUAGE="JavaScript">
<!-- Begin hiding
function setCookie(){
document.cookie="disclaimer=viewed";
}
function noway(){
var goodbye="http://www.google.com";
window.location=goodbye;
}
// End hiding -->
</script>
</head>
<body>
.
.
.
<a onclick="setCookie(); javascript:history.go(-1)">
<img border="0" id="img1" src="images/buttonE.jpg" height="20" width="100" alt="I Accept">
<a onclick="noway()">
<img border="0" id="img2" src="images/button18.jpg" height="20" width="100" alt="I Decline">
.
.
.
</body>
|