关闭的时候可以onbeforeunload()方法
我把我项目的一段拷贝给你看
//Written by Milo on Oct 22th,2010
//新增或者修改状态下离开该画面提示保存消息
window.onbeforeunload = function(){
if(editing)
{
return "离开此画面可能造成尚未保存的资料丢失。"
}
}
真的不行,换句话,没有办法的。<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8">
<title>无标题文档</title>
<script type="text/javascript">
function isMinStatus() {
var isMin = false
if (window.outerWidth != undefined) {
isMin = window.outerWidth <= 160 &&window.outerHeight <= 27
}
else {
isMin = window.screenTop <-30000 &&window.screenLeft <-30000
}
return isMin
alert(111)
}
function notifyTeacher(){
alert('document.body.offsetTop:'+document.body.offsetTop+',document.body.offsetWidth:'+document.body.offsetWidth+',screen.availWidth:'+screen.availWidth+',top.screenTop:'+top.screenTop)
alert('window.screen.width:'+window.screen.width+',window.screen.height:'+window.screen.height+',window.screen.availWidth:'+window.screen.availWidth+',window.screen.availHeight:'+window.screen.availHeight)
alert(top.name)
alert(top.screenTop+'|'+top.screenLeft)
if(isMinStatus()){
window.focus()
}else{
document.focus()
}
}
</script>
</head>
<body onLoad="notifyTeacher()">
</body>
</html>
可以用js控制最小化的浏览器窗口桔黄闪动提示新信息,控制title文字就行。具体如下://取title
var title = document.getElementsByTagName('title')[0]
//需要修改的时候,直接给innerHTML复制
var title.innerHTML = '这里在闪'。