用javascript写的热键例子

来源:互联网 发布:mac可用的画图软件 编辑:程序博客网 时间:2024/04/18 13:29

脚本说明:
第一步:把如下代码加入
<head>区域中

  1. <SCRIPT language="JavaScript">
  2. <!--
  3. var hotkey=97
  4. var destination="zh1.htm"
  5. if (document.layers)
  6. document.captureEvents(Event.KEYPRESS)
  7. function backhome(e){
  8. if (document.layers){
  9. if (e.which==hotkey)
  10. window.location=destination
  11. }
  12. else if (document.all){
  13. if (event.keyCode==hotkey)
  14. window.location=destination
  15. }
  16. }
  17. document.onkeypress=backhome
  18. //-->
  19. </SCRIPT>
第二步:把<body>区域改为
  1. <body bgcolor="#fef4d9" onload="begintimer()">

原创粉丝点击