怎么通过输入一个密码关闭网页 <body onUnload="checkPass();"><script>Function checkPass() {var pass=promt();...}</script> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 var ttt=document.getElementById("inputnum")if(ttt.value=="xxxx"){window.close();} <form name=form1><input type=text name=text1> //输入密码<input type=submit onclick=closewin()> //调用下面的函数</form><script>function closewin(){if(document.form1.text1.value=="xxxx") //xxxx为密码{window.close();}else{alert("错误的密码,请重新输入")}}</script> 上面代码测试可行,输入xxxx就关闭窗口,你可新建个txt文档文件把代码COPY过去,改名为xxx.htm即可不过有提示说你是不是关闭窗口,如不要提示可用下面代码,加一个opener=null<form name=form1><input type=text name=text1> //输入密码<input type=submit onclick=closewin()> //调用下面的函数</form><script>function closewin(){if(document.form1.text1.value=="xxxx") //xxxx为密码{opener=nullwindow.close();}else{alert("错误的密码,请重新输入")}}</script> 正则匹配图片 求助,文字上下滚动问题! 就这两三行,求会的帮忙~ 为什么JavaScript中的函数不起作用? 怎样实现图片定位在页面的一个固定位置! 在使用框架时(Frame),是否可以不使用滚动条,而让窗口自动放大和缩小? 如何打开文件目录浏览的对话框啊! js获取url的问题。 jQurey的mouseenter事件 easyui 使用datagrid合并表格时表头与表体不对应问题 请问这几个属性是做什么的? 如何屏蔽网页刷新?
if(ttt.value=="xxxx"){
window.close();
}
<input type=text name=text1> //输入密码
<input type=submit onclick=closewin()> //调用下面的函数
</form><script>
function closewin()
{
if(document.form1.text1.value=="xxxx") //xxxx为密码
{
window.close();
}
else
{
alert("错误的密码,请重新输入")
}
}
</script>
<input type=text name=text1> //输入密码
<input type=submit onclick=closewin()> //调用下面的函数
</form><script>
function closewin()
{
if(document.form1.text1.value=="xxxx") //xxxx为密码
{
opener=null
window.close();
}
else
{
alert("错误的密码,请重新输入")
}
}
</script>