回答
你可以使用的onkeydown方法。
document.onkeydown = function(){
if(window.event && window.event.keyCode == 113)
{
window.location.href = "http://www.yoursite.com"
}
}
在這裏,你可以用任何東西來代替113.F2是113 ascii.F1是112,F3是114等等。
它的工作原理感謝.. .. –
歡迎您... –
document.onkeydown = function(){
if(window.event && window.event.keyCode == 113)
{
window.location.href = "http://www.google.com"
}
}
感謝指出了這一點... –
的可能重複。我想,該重定向的正確語法是:'window.location.href ='https://www.google.co.in';'。 – 2014-02-18 05:13:59
在這裏,你有使用jQuery您的要求的實現:的jsfiddle。淨/ 96rLf/2。
主要部分是這樣的:jsfiddle.net/96rLf/2. 您可以使用jQuery
<input type="button" accesskey="?" value="Next Item">
$(window).keydown(function(e) {
switch (e.keyCode) {
case 37: case 38: //key is left or up
if (currImage <= 1) {break;} //if is the first one do nothing
goToPrev(); // function which goes to previous image
return false; //"return false" will avoid further events
case 39: case 40: //key is left or down
if (currImage >= maxImages) {break;} //if is the last one do nothing
goToNext(); // function which goes to next image
return false; //"return false" will avoid further events
}
return; //using "return" other attached events will execute
});
<html>
<head>
<script>
document.addEventListener("keydown", keyDown, false);
function keyDown(e)
{
var keyCode = e.keyCode;
if(keyCode==113) {window.location.href = "http://www.google.com";}
}
</script>
</head>
<body>
<a href="https://www.google.co.in">Google.com</a>
</body>
</html>
其工作感謝.... –
- 1. 如何通過按下按鈕打開新選項卡中的鏈接?在玉
- 2. 通過Html按鈕打開文件
- 3. 在Webview中打開按鈕鏈接
- 4. 通過按鈕打開SlidingDrawer
- 5. 如何通過按鈕打開infowindow
- 6. 如何通過按鈕打開SlidingPanelLayout?
- 7. Android按鈕在後臺打開鏈接?
- 8. 如何通過引導將按鈕鏈接到按鈕上?
- 9. 如何打開鏈接按鈕文檔onClick按
- 10. 如何通過自定義按鈕打開HTML選擇標籤?
- 11. 居中html按鈕鏈接
- 12. 通過點擊html內的鏈接打開一個新的視圖(按鈕)
- 13. 如何在新標籤頁中隨機鏈接中打開HTML按鈕
- 14. 如何使用contenttools通過(按鈕)鏈接編輯html?
- 15. 如何在單獨的選項卡中打開鏈接(按鈕)?
- 16. 如何在單元格中添加按鈕以打開鏈接
- 17. 通過通知按鈕打開藍牙
- 18. HTML - 表單中的按鈕打開鏈接
- 19. PureBasic - 如何模擬按F1或F2鍵盤按鈕?
- 20. 如何讓我的flash按鈕(嵌入在html代碼中)打開鏈接?
- 21. 如何創建一個在.php表格中打開鏈接的HTML按鈕?
- 22. 按鈕上的打開鏈接
- 23. 超鏈接按鈕始終打開google.com
- 24. Android使用按鈕打開EditText鏈接
- 25. 如何通過按下按鈕打開pdf?
- 26. 如何通過按鈕在c#中打開記事本
- 27. 如何通過按下Google App腳本UIApp中的按鈕打開當前窗口中的鏈接?
- 28. 如何允許用戶右鍵單擊按鈕或鏈接按鈕以在新選項卡中打開
- 29. HTML超鏈接按鈕
- 30. PHP倒數過期按鈕或鏈接
[元素的onkeydown鍵碼的javascript](http://stackoverflow.com/questions/1629926/element-onkeydown-keycode-javascript) –