下载站常用的点击下载地址提示设hao123为首页的js代码
人气:0效果图:
核心代码:
<script>
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value)
{
var second = 15*60; //多少秒
var exp = new Date();
exp.setTime(exp.getTime() + second*1000);
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((exp == null) ? "" : ("; expires=" + exp.toGMTString())) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function $(id){return document.getElementById(id);}
$("downAddress").onclick = function () { address_click(); }
/https://img.qb5200.com/download-x/downAddress就是下载区域所在的id,如果是class的需要修改下,如果你使用的jquery可以根据需要设置下就可以了
var isTrue = false;
var userHome = GetCookie("isHome");
function address_click()
{
if(userHome == null || userHome == "")
{if(!isTrue)
{
document.body.style.behavior="url(#default#homepage)";
document.body.setHomePage('http://www.hao123.com/?tn=92961071_hao_pg');
SetCookie("isHome","yes");
userHome = "yes"
}
}
return true;
}
</script>
下面附上一个更简单的点击设置首页的代码,跟上面的没有关系,下面的事通过单个链接的onclick触发的,大家可以根据需要修改
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
加载全部内容