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>

It may be a difference in the way a particular browser stores cookies.

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.