正 文

给页面定义热键


www.7dspace.com  更新日期:2005-8-16 4:26:01  七度空间


把下面代码copy入你html文件的<head>和</head>中再按一下b键试试:


<script>
var travel=true
var hotkey=98 /* hotkey即为热键的键值,是ASII码,这里98代表b键 */
var destination="../index.htm" /* 在此定义热键对应的页面 */
if (document.layers)
document.captureEvents(Event.KEYPRESS)
function gogo(e){
if (document.layers){
if (e.which==hotkey&&travel)
window.location=destination
}
else if (document.all){
if (event.keyCode==hotkey)
window.location=destination
}
}
document.onkeypress=gogo
</script>


上一篇:主页反馈表单的制作
下一篇:网站设计37条原则
作者:  来源: ( 责任编辑:7dspace )
收藏此页】【打印】【关闭
站 内 搜 索
 

热 点 导 读
特 别 推 荐