我有一个倒计时的网页,并重定向到上一页,效果很好,但我想要关闭页面(当前浏览器标签),而不是重定向到上一页。消失。自毁。
我尝试用history.go(-1)
替换我的重定向window.close()
,但它没有用。
JS:
var countdownfrom=9
var currentsecond=document.redirect.redirect2.value=countdownfrom+1
function countredirect(){
if (currentsecond!=1){
currentsecond-=1
document.redirect.redirect2.value=currentsecond
}
else{
history.go(-1)
return
}
setTimeout("countredirect()",1000)
}
countredirect()
HTML:
<form name="redirect">
<h1>Oops! I think you meant to use a URL...</h1>
<h2>this page will self destruct in</h2>
<form>
<input type="text" size="1" name="redirect2">
</form>
<h2>seconds</h2>
<h3>Go back to where you came from and try again!</h3>
html看起来不对,你甚至可以将表单嵌套在另一个表单中吗?它工作正常。
<h1>Oops! I think you meant to use a URL...</h1>
<h2>this page will self destruct in</h2>
<form name="redirect">
<input type="text" size="1" name="redirect2">
</form>
<h2>seconds</h2>
<h3>Go back to where you came from and try again!</h3>