📄 read_cookie.htm
字号:
<html>
<head>
<title>Reading the Cookie</title>
<!-- HELLO HOWDY SHALOM YO MAMA -->
<!-- I JUST HAD TO ADD SOME CODE TO -->
<!-- MAKE THIS WORK ON HOTWIRED SERVERS -->
<!-- I DIDN'T REALLY MEAN THE YO MAMA THING -->
<!-- PLEASE DON'T HURT ME -->
<script language="JavaScript">
<!-- hide me
function readCookie()
{
var the_cookie = WM_readCookie("wm_javascript");
var broken_cookie = the_cookie.split(":");
var the_name_part = broken_cookie[1];
var broken_name = the_name_part.split(";");
var the_name = broken_name[0];
alert("Your name is: " + unescape(the_name));
}
function WM_readCookie(name) {
// if there's no cookie, return false else get the value and return it
if(document.cookie == '') return false;
else return unescape(WM_getCookieValue(name));
}
function WM_getCookieValue(name)
{
// Declare variables.
var firstChar, lastChar;
// Get the entire cookie string. (This may have other name=value pairs in it.)
var theBigCookie = document.cookie;
// Grab just this cookie from theBigCookie string.
// Find the start of 'name'.
firstChar = theBigCookie.indexOf(name);
// If you found it,
if(firstChar != -1)
{
// skip 'name' and '='.
firstChar += name.length + 1;
// Find the end of the value string (i.e. the next ';').
lastChar = theBigCookie.indexOf(';', firstChar);
if(lastChar == -1) lastChar = theBigCookie.length;
// Return the value.
return theBigCookie.substring(firstChar, lastChar);
} else {
// If there was no cookie, return false.
return false;
}
}
// show me-->
</script>
</head>
<body>
<h3>读取Cookie</h3>
<p>上页中你输入的信息被存储在你的硬盘上。点击这里来<br>
<a href="#" onClick="readCookie(); return false;">读取你硬盘上的cookie</a>。此信息会保存在你的硬盘上,<br>
即使你退出浏览器。试试看,退出浏览器,然后返回此<br>
页再点击这个连接。它还记着你的名字,是吧? 如果是<br>
这样,让我们接着学吧。<a href="day2_8.html">>></a></p>
</body>
</html>
</ht>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -