close window

----------------例子1------------
代码:
< script >

window.onbeforeunload 
= function() 
{
alert(
"111222");
  
var n = window.event.screenX - window.screenLeft;
  
var b = n > document.documentElement.scrollWidth-20;
  
if(b && window.event.clientY < 0 || window.event.altKey)
  
{
    window.event.returnValue 
= ""
  }

}



</ script >
<!--    方法2 
<script language=javascript>
window.onbeforeunload = function()
{
  if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
  {
    window.event.returnValue = "";
  }
}
</script>
-->

<!--    方法3
如何让IE6.0右上角的“关闭”按钮失效?
实例1即可实现。
-----------------------------------
<script language=javascript>
window.onbeforeunload = function()
{
  if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
  {
    window.event.returnValue = "";
  }
}
</script>

2----------------------
没有关闭按扭
window.open("","","fullscreen=3")

3----------------------
屏蔽alt+f4
if (window.event.altKey && k == 115){
return false;
}
将1.复制到WEB页面中任何位置即可。J)育)kI{t育|1WRd%1

供教F2络z管.育M软d0

络mr5H7I*业.4"s
z教络kt&!va业5$s^:

eQ1x3Ad%l中~DK网NH教dBziNoq$n\+-
$@0R中[件rn2w*69

-->
----------------例子2------------
代码:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
< html >
< head >
< title > Confirm Before Leave </ title >
< script  language ="javascript"  type ="text/javascript" > <!--
var pb_strConfirmCloseMessage;
var pb_blnCloseWindow = false;
pb_strConfirmCloseMessage 
="您真的要离开本页吗?";
function ConfirmClose() {
window.event.returnValue 
= pb_strConfirmCloseMessage;
pb_blnCloseWindow 
= true;
}

function ShowConfirmClose(blnValue) {
if(blnValue) {
document.body.onbeforeunload 
= ConfirmClose;
}
 else {
document.body.onbeforeunload 
= null;
}

}

//-->
</ script >
</ head >
< body  onload ="ShowConfirmClose(true);" >
< input  type =button  value ="提示"  onclick ="ShowConfirmClose(true);" >
< input  type =button  value ="不提示"  onclick ="ShowConfirmClose(false);" >
< input  type =button  value ="测试刷新"  onclick ="window.location.reload();" >
</ body >
</ html >
----------------例子3------------
代码:
< html >    
  
< head >    
  
< meta    http-equiv ="Content-Type"    content ="text/html;   charset=iso-8859-1" >    
  
< OBJECT    id =closes    type ="application/x-oleobject"    classid ="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" >      
  
< param    name ="Command"    value ="Close" >      
  
</ object >    
  
</ head >    
  
< body >    
  
< p    align ="center" >< font    size ="6" >    
  
< input    type ="button"    value ="CLOSE"    onclick ="closes.Click();" >    
  
</ font ></ p >    
  
</ body >    
  
</ html >
----------------例子4------------
代码:
< script  language ="javascript" >
  g_blnCheckUnload 
= true;
  
function RunOnBeforeUnload() {
     
if (g_blnCheckUnload) {window.event.returnValue = 'You will lose any unsaved content';   
     }
  
  }

</ script >
< body   onbeforeunload ="RunOnBeforeUnload()" >
</ body >
本文转自博客园执着的笨蛋的博客,原文链接:close window ,如需转载请自行联系原博主。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值