Httml Code:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title>untitled document</title>
<body>
<a href= "Javascript:sethome (' Dizhi1 ')" >Website1</a>
<a href= "Javascript:sethome (' Dizhi2 ')" >Website2</a>
<a href= "Javascript:sethome (' Dizhi3 ')" >Website3</a>
<a href= "Javascript:sethome (' Dizhi4 ')" >Website4</a>
<form name= "Homeform" method= "POST" >
<input type= "checkbox" Name= "Setgo" value= "1" > Remember my choices
</form>
</body>
JS Code:
Copy Code code as follows:
<script language= "JavaScript" type= "Text/javascript" >
<!--
function GetCookie (name) {
if (Document.cookie.length > 0) {
Start = document.cookie.indexOf (name + "=");
If (Start!=-1) {
Start = start +name.length + 1;
End = Document.cookie.indexOf (";", start);
if (end = = 1) {
end = Document.cookie.length;
}
Return decodeURI (document.cookie.substring (start,end));
}
}
Return "";
}
function Setcookie (name, value, expires, path, domain, secure) {
var Curcookie = name + "=" +encodeuri (value)
+ ((expires)? "; expires=" + expires.togmtstring (): "")
+ (path)? ";p ath=" + Path: "")
+ (domain)? ";d omain=" + domain: "")
+ (Secure)? "; Secure": "");
Document.cookie = Curcookie;
}
function GoHome (myhome) {
if (myhome) {
Switch (myhome) {
Case "DIZHI1":
window.location = "http://www.qq.com";
Break
Case "Dizhi2":
window.location = "http://zghlx.cnblogs.com";
Break
Case "Dizhi3":
window.location = "http://www.sina.com.cn";
Break
Case "DIZHI4":
window.location = "http://www.163.com";
Break
}
}
}
function Sethome (myhome) {
var today = new Date ();
var expires = new Date ();
Expires.settime (Today.gettime () + 365*24*60*60*1000);
if (document.homeform.setgo.checked) {
Setcookie ("Home", myhome,expires);
}
GoHome (MyHome);
}
Window.onload = function () {
var phome = GetCookie ("Home");
GoHome (Phome);
}
-->
</script>