網(wǎng)(LieHuo.Net)教程 JavaScript接收鍵盤指令示例,按下鍵盤上不同的鍵,程序會(huì)跳轉(zhuǎn)到不同的網(wǎng)頁(yè),本例中按下B鍵后,為跳轉(zhuǎn)到網(wǎng)首頁(yè),實(shí)現(xiàn)按鍵跳轉(zhuǎn)的功能。
<html><head><title>請(qǐng)按下鍵盤上的 B 鍵,會(huì)跳轉(zhuǎn)到網(wǎng)的首頁(yè)</title><head><body>請(qǐng)按下鍵盤上的 B 鍵,會(huì)跳轉(zhuǎn)到網(wǎng)的首頁(yè)<SCRIPT language="JavaScript"><!--var hotkey=98var destination="http://www.jyygyx.com/"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>網(wǎng)更多教程,請(qǐng)?jiān)L問(wèn):<a href=http://www.jyygyx.com/ target=_blank _fcksavedurl="http://www.jyygyx.com/ target=_blank">http://www.jyygyx.com/</a></center>提示:可修改后代碼再運(yùn)行!
上一篇 四條重要秘訣讓你的網(wǎng)站吸引瀏覽者
下一篇 MyEclipse安裝ExtJS插件Spket IDE的教程
程序員人生,我編程,我富裕,記住wfuyu網(wǎng),php教程,php學(xué)習(xí),php手冊(cè),CMS模版制作
聲明:本站大部分內(nèi)容是作者原創(chuàng),少部分收集于互聯(lián)網(wǎng)供大家一起學(xué)習(xí),原版權(quán)很多不明,如有侵權(quán)請(qǐng)聯(lián)系本站,謝謝!
粵ICP備14040726號(hào)-1?? 2015-2020 程序員人生 版權(quán)所有