让网页定时关闭
转自:让网页定时关闭
下面是代码:直接复制,Chrome下,Ctrl+Shift+I,粘贴回车即可
javascript:console.log('%c本页面一小时后关闭', 'background-image:-webkit-gradient( linear, left top, right top, color-stop(0, #f22), color-stop(0.15, #f2f), color-stop(0.3, #22f), color-stop(0.45, #2ff), color-stop(0.6, #2f2),color-stop(0.75, #2f2), color-stop(0.9, #ff2), color-stop(1, #f22) );color:transparent;-webkit-background-clip: text;font-size:5em;');var t = 3600;function fun(){t--;console.warn(t+'秒');if(t<=0){window.opener = null;window.open('', '_self');window.close();clearInterval(inter);}}var inter = setInterval('fun()',1000);
代码这样看比较乱,其实加上换行,就很清楚明了了:(代码中的换行违反语法规则,这样写只是为了看起来方便)
console.log('%c本页面一小时后关闭', '
background-image:-webkit-gradient(
linear, left top, right top,
color-stop(0, #f22),
color-stop(0.15, #f2f),
color-stop(0.3, #22f),
color-stop(0.45, #2ff),
color-stop(0.6, #2f2),
color-stop(0.75, #2f2),
color-stop(0.9, #ff2),
color-stop(1, #f22)
);
color:transparent;
-webkit-background-clip: text;
font-size:5em;
');
var t = 3600;
function fun(){
t--;
console.warn(t+'秒');
if(t<=0){
window.opener = null;
window.open('', '_self');
window.close();
clearInterval(inter);
}
}
var inter = setInterval('fun()',1000);
标签:上网技巧