•
•
•
•
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
![]() |
•
•
Join Date: Jan 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Hi all, I'm learning JavaScript and have run into a problem. Displaying the contents of a cookie with the code 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:
alert(document.cookie);
<!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> 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."
"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."
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
ajax apple asp browser cross-browser javascript menu with few lines of code developer development firefox home html internet javascript javascript smooth scrolling scroll smoothly window document position javascript tab menu with rounded corners generator microsoft msdn news office prevent javascript menu from getting hidden under flash movies safari site software sql vista web windows
- Previous Thread: AutoScrolling a DIV tag
- Next Thread: How to link towards a div tag?



Linear Mode