網(LieHuo.Net)教程 JavaScript接收鍵盤指令示例,按下鍵盤上不同的鍵,程序會跳轉到不同的網頁,本例中按下B鍵后,為跳轉到網首頁,實現按鍵跳轉的功能。
<html><head><title>請按下鍵盤上的 B 鍵,會跳轉到網的首頁</title><head><body>請按下鍵盤上的 B 鍵,會跳轉到網的首頁<SCRIPT language="JavaScript"><!--var hotkey=98var destination="http://www.vxbq.cn/"if (document.layers)document.captureEvents(Event.KEYPRESS)function backhome(e){if (document.layers){if (e.which==hotkey)window.location=destination}else if (document.all){if (event.keyCode==hotkey)window.location=destination}}document.onkeypress=backhomeonkeydown="javascript:onenter();"function onenter(){if(event.keyCode==13){alert("回車");}}</SCRIPT></body></html><br /><center>網更多教程,請訪問:<a href=http://www.vxbq.cn/ target=_blank _fcksavedurl="http://www.vxbq.cn/ target=_blank">http://www.vxbq.cn/</a></center>提示:可修改后代碼再運行!
上一篇 四條重要秘訣讓你的網站吸引瀏覽者
下一篇 MyEclipse安裝ExtJS插件Spket IDE的教程
程序員人生,我編程,我富裕,記住wfuyu網,php教程,php學習,php手冊,CMS模版制作
聲明:本站大部分內容是作者原創,少部分收集于互聯網供大家一起學習,原版權很多不明,如有侵權請聯系本站,謝謝!
粵ICP備14040726號-1?? 2015-2020 程序員人生 版權所有