熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

禁止網頁頁面刷新的特效代碼

2022-06-13   來源: JSP教程 
<html>
<meta httpequiv=ContentType content=text/html; charset=gb>
<head>
<script language=javascript>
var ie  =navigatorappName==Microsoft Internet Explorer?true:false;
  
function keyDown(e)
{
 if(!ie)
 {
  var nkey=ewhich;
  var iekey=現在是ns浏覽器;
  var realkey=StringfromCharCode(ewhich);
 }
 if(ie)
 {
  var iekey=eventkeyCode;
  var nkey=現在是ie浏覽器;
  var realkey=StringfromCharCode(eventkeyCode);
  if(eventkeyCode==){realkey=\ 空格\}
  if(eventkeyCode==){realkey=\ 回車\}
  if(eventkeyCode==){realkey=\ Esc\}
  if(eventkeyCode==){realkey=\ Shift\}
  if(eventkeyCode==){realkey=\ Ctrl\}
  if(eventkeyCode==){realkey=\ Alt\}
 }
 alert(ns浏覽器中鍵值:+nkey+\n+ie浏覽器中鍵值:+iekey+\n+實際鍵為+realkey);
}
documentonkeydown = keyDown;
</script>
</head>
<body>
//Javascript Document
<hr>
<center>
<h>請按任意一個鍵</h>
</center>
</body>
</html>

From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19587.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.