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 >

你可能感兴趣的:(JavaScript,html,Web,J#)