location對(duì)象使用
網(wǎng)頁(yè)重定向
location.;
獲取項(xiàng)目的根url
location.origin
Cookies基本用法
- 存基本數(shù)據(jù),kidd
var name = "kidd";
document.cookie = "name="+name; - 讀取cookies里面的數(shù)據(jù)
function getCookie(name)
{
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
var name = getCookie('name'); - 存儲(chǔ)有時(shí)間有效期的cookies數(shù)據(jù),cookies默認(rèn)會(huì)在瀏覽器關(guān)閉時(shí)清除,如果沒有設(shè)置有效期
function setCookie(name,value)
{
var Days = 7;
var exp = new Date();
exp.setTime(exp.getTime() + 10*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}