关闭浏览器窗口JS弹窗提示

JavaScript031

关闭浏览器窗口JS弹窗提示,第1张

<!doctype html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title></title>

<script>

window.onload = function(){

var form = document.forms[0]

form.onsubmit = function(){

// 注销onbeforeunload事件

window.onbeforeunload = null

// 这个是关闭窗口用作测试 并不能提交

// 正确的做法是在提交页面关闭窗口

window.close()

}

window.onbeforeunload = function(e){

e.returnValue = '数据提交是否退出?'

}

}

</script>

</head>

<body>

<form action="php/test.php">

<input type="submit">

</form>

</body>

</html>

第一种:JS定时自动关闭窗口

<script language="javascript"><!--function closewin(){self.opener=null

self.close()}function clock(){i=i-1document.title="本窗口将在" + i + "秒后自动关闭!"

if(i>0)setTimeout("clock()",1000)

else closewin()}var i=10clock()//--></script>第二种:点击链接没有提示的JS关闭窗口

<a href="javascript:window.close()" >关闭窗口</a>

第三种:窗口没有提示自动关闭的js代码

<script language=javascript><!--this.window.opener = null

window.close()//--></script>IE6-7 JS关闭窗口不提示的方法方法一:js 代码function CloseWin() //这个不会提示是否关闭浏览器{window.opener=null

//window.opener=top

window.open("","_self")

window.close()}方法二:open.htmljs 代码function open_complex_self() {

var obj_window = window.open('close.html', '_self')

obj_window.opener = window

obj_window.focus()}close.htmljs 代码window.close()另附://普通带提示关闭

function closeie(){

window.close()}//关闭IE6不提示

function closeie6(){

window.opener=null

window.close()}//关闭IE7不提示

function closeie7(){