Esc建实现关闭窗体

MyHtml.html

<script type="text/javascript" language="javascript">// <![CDATA[ function esckeydown() { if(event.keyCode==27){ event.returnValue = null; window.returnValue = null; window.close(); } } //document.onkeydown=esckeydown; function esckeydownHide() { if(event.keyCode==27){ document.getElementById('test').style.display='none'; } } document.onkeydown=esckeydownHide; function test(){ document.getElementById('test').style.display='block'; } // ]]></script>
aaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaa

test

<!DOCTYPE html>
<html>
  <head>
    <title>MyHtml.html</title>
	
    <meta name="keywords" content="keyword1,keyword2,keyword3">
    <meta name="description" content="this is my page">
    <meta name="content-type" content="text/html; charset=UTF-8">
    
  <script language="javascript">
	function esckeydown()
	{
		if(event.keyCode==27){
		   event.returnValue = null;
		   window.returnValue = null;
		   window.close();
		}
	}
	//document.onkeydown=esckeydown;
	
	
	function esckeydownHide()
	{
		if(event.keyCode==27){
			
			document.getElementById('test').style.display='none';
		}
	}
	document.onkeydown=esckeydownHide;
	function test(){
		document.getElementById('test').style.display='block';
	}
</script>

  </head>
  
  <body>
   	<div style="height: 200px;width: 200px;display:none" id="test">
   	aaaaaaaaaaaaaaaaaaaaaaaaaaaa
   	aaaaaaaaaaaaaa
   	aaaaaaaaaaaaaa
   	aaaaaaaaaaaaaa
   	aaaaaaaaaaaaaa
   	</div>
   	
   	<a href="javascript:void(0);" onclick="test()">test</a>
  </body>
</html>

 

你可能感兴趣的:(JavaScript)