<script language= "javascript"> function setCookie() { var the_name=prompt( "what 's your name? ", " "); var the_cookie= "wm_javascript=username: "+escape(the_name); document.cookie=the_cookie; alert( "Thanks,now go to the next page. "); return; } function readCookie() { var the_cookie=document.cookie; var broken_cookie=the_cookie.split( ": "); var the_name=broken_cookie[1]; var the_name=unescape(the_name); alert( "Your name is: "+the_name); } alert( "Your name is: "+the_name); setCookie() readCookie() </script> 你需要调用
<script language= "javascript"> var the_name function setCookie() { the_name=prompt( "what 's your name? ", " "); var the_cookie= "wm_javascript=username: "+escape(the_name); document.cookie=the_cookie; alert( "Thanks,now go to the next page. "); return; } function readCookie() { var the_cookie=document.cookie; var broken_cookie=the_cookie.split( ": "); var the_name=broken_cookie[1]; var the_name=unescape(the_name); alert( "Your name is: "+the_name); } setCookie() readCookie() alert( "Yourname is: "+the_name); </script> 注意变量的作用域,放外面定义
{
var the_name=prompt( "what 's your name? ", " ");
var the_cookie= "wm_javascript=username: "+escape(the_name);
document.cookie=the_cookie;
alert( "Thanks,now go to the next page. ");
return;
}
function readCookie()
{
var the_cookie=document.cookie;
var broken_cookie=the_cookie.split( ": ");
var the_name=broken_cookie[1];
var the_name=unescape(the_name);
alert( "Your name is: "+the_name);
}
alert( "Your name is: "+the_name);
setCookie()
readCookie()
</script> 你需要调用
var the_name
function setCookie()
{
the_name=prompt( "what 's your name? ", " ");
var the_cookie= "wm_javascript=username: "+escape(the_name);
document.cookie=the_cookie;
alert( "Thanks,now go to the next page. ");
return;
}
function readCookie()
{
var the_cookie=document.cookie;
var broken_cookie=the_cookie.split( ": ");
var the_name=broken_cookie[1];
var the_name=unescape(the_name);
alert( "Your name is: "+the_name);
}
setCookie()
readCookie()
alert( "Yourname is: "+the_name); </script>
注意变量的作用域,放外面定义