JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 4th, 2004, 12:16 AM
Craig B Craig B is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 4 Craig B User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Script works in IE but not NS... How can I fix this?

URLPosted: 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>  

Reply With Quote
  #2  
Old April 10th, 2004, 01:17 PM
Craig B Craig B is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 4 Craig B User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ok.. problem solved

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Script works in IE but not NS... How can I fix this?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT