User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 374,007 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,907 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 683 | Replies: 2
Reply
Join Date: Jan 2008
Posts: 1
Reputation: earachefl@comca is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
earachefl@comca earachefl@comca is offline Offline
Newbie Poster

Displaying cookie contents in safari?

  #1  
Jan 7th, 2008
Hi all, I'm learning JavaScript and have run into a problem. Displaying the contents of a cookie with the code
 alert(document.cookie); 
works fine in Firefox 2.0.0.11, but in Safari 3.0.4, it just displays an empty alert box. Any quick answers? Any resources that you can point me to? Thanks in advance, and here's the complete code:

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" 
	"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>App 8.1</title>

<script type="text/javascript" >
<!--
 	function submitForm(form) {
		document.cookie = "userName=" + form.userName.value;
		alert(document.cookie);
		if(form.userName.value == "") {
			alert("No name was entered.");
			return false;
		}
		else {
			alert("Cookie value is\n" + document.cookie);
			return false;
		}
	}
//-->
</script>
</head>

<body>
<form>
	Your name here:
	<input type="text" name="userName" value="">
	<input type="button" name="submit" value="Submit!" onClick="submitForm(this.form);">
</form>

</body>
</html>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2007
Posts: 2,433
Reputation: MidiMagic is on a distinguished road 
Rep Power: 6
Solved Threads: 99
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Posting Maven

Re: Displaying cookie contents in safari?

  #2  
Jan 8th, 2008
It may be a difference in the way a particular browser stores cookies.
Daylight-saving time uses more gasoline
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,731
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 323
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: Displaying cookie contents in safari?

  #3  
Jan 10th, 2008
Read the part about document.cookie on this page. You are missing some important bits and pieces in your cookie creation code. Also it would be interesting to note that the cookie property of the document is not of type string though it normally is treated like one. Taking care of this should most probably solve your issue.
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 10:41 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC