记录cookies实现退出弹出“设为主页”代码
记录cookies实现退出弹出“设为主页”代码
[code]<script>
function getCookie(name) {
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ';', len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
function SetCookie(name,value)//两个参数,一个是cookie的名子,一个是值
{
var Days = 1; //此 cookie 将被保存 1 天
var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function setpage(aa,str){
//注意,只对IE有效,FF需要修改浏览器设置
aa.style.behavior="url(#default#homepage)";
var bb=getCookie("username"); //读取cookies
if (bb!='easyplay8er')
{
aa.setHomePage(str);
SetCookie("username","easyplay8er");
}
}
</script>
<body onclick="setpage(this,'http://www.suanbu.com');">
</body>[/code]