【www.gdgbn.com--js教程】
下面我们一个网站弹出窗口代码,我今天 把它分享给各位朋友。
<script>
var domain = "#foo";
function isie(){
if (window.navigator.useragent.tolowercase().indexof("msie")>=1)
return true;
else
return false;
}
if(!isie()){
try {
document.createelement("a");
htmlelement.prototype.click = function () {
if (typeof this.onclick == "function") {
if (this.onclick({type: "click"}) && this.href)
window.open(this.href, this.target? this.target : "_self");
}
else if (this.href)
window.open(this.href, this.target? this.target : "_self");
};
}
catch (e) {
}
}
function setcookie(name, value, expire) {
window.document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.togmtstring()));
}
function getcookie(name) {
var search = name + "=";
if (window.document.cookie.length > 0) { // if there are any cookies
offset = window.document.cookie.indexof(search);
if (offset != -1) { // if cookie exists
offset += search.length; // set index of beginning of value
end = window.document.cookie.indexof(";", offset) // set index of end of cookie value
if (end == -1)
end = window.document.cookie.length;
return unescape(window.document.cookie.substring(offset, end));
}
}
return null;
}
function register(name) {
var today = new date();
var expires = new date();
expires.settime(today.gettime() + 1000*60*60*24);
setcookie("dacontrol-hcy-vmgou", name, expires);
}
function close_self() {
window.open("","_parent","");
window.top.opener = null;
window.close();
}
function navi(){
var c=getcookie("dacontrol-hcy-vmgou");
if( c != null) close_self();
else
{
register("done");
document.getelementbyid("adurl").click();
}
}
</script>
<script>
var c=getcookie("dacontrol");
if( c != null) close_self();
</script>