用js实现键盘方向键翻页功能的代码_javascript技巧
程序员文章站
2022-06-12 16:15:49
...
今天从网上看到这个功能,不错啊,以后就可以在文章中,增加这个功能了
var re = /[\[\(]?/igm;
if (window.document.body.innerHTML.search(re) >= 0) {
var PREVIOUS_PAGE = RegExp.$1;
}
如果搜下到"上一页",则定义var PREVIOUS_PAGE = RegExp.$1;
var re = /[\[\(]?/igm;
if (window.document.body.innerHTML.search(re) >= 0) {
var NEXT_PAGE = RegExp.$1;
}
如果搜下到"下一页",则定义var NEXT_PAGE = RegExp.$1;
if (typeof PREVIOUS_PAGE == "string" || typeof NEXT_PAGE == "string") {
document.onkeydown = function() {
switch (event.srcElement.tagName) {
case "INPUT":
case "TEXTAREA":
case "SELECT":
break;
default:
if (event.keyCode == 37 /* Arrow Left*/ && typeof PREVIOUS_PAGE == "string") {
window.location.href = PREVIOUS_PAGE;
}
else if (event.keyCode == 39 /* Arrow Right */ && typeof NEXT_PAGE == "string") {
window.location.href = NEXT_PAGE;
}
}
}
}
var re = /[\[\(]?/igm;
if (window.document.body.innerHTML.search(re) >= 0) {
var PREVIOUS_PAGE = RegExp.$1;
}
如果搜下到"上一页",则定义var PREVIOUS_PAGE = RegExp.$1;
var re = /[\[\(]?/igm;
if (window.document.body.innerHTML.search(re) >= 0) {
var NEXT_PAGE = RegExp.$1;
}
如果搜下到"下一页",则定义var NEXT_PAGE = RegExp.$1;
if (typeof PREVIOUS_PAGE == "string" || typeof NEXT_PAGE == "string") {
document.onkeydown = function() {
switch (event.srcElement.tagName) {
case "INPUT":
case "TEXTAREA":
case "SELECT":
break;
default:
if (event.keyCode == 37 /* Arrow Left*/ && typeof PREVIOUS_PAGE == "string") {
window.location.href = PREVIOUS_PAGE;
}
else if (event.keyCode == 39 /* Arrow Right */ && typeof NEXT_PAGE == "string") {
window.location.href = NEXT_PAGE;
}
}
}
}
上一篇: php用curl抓取网页问题
推荐阅读
-
用js实现键盘方向键翻页功能的代码_javascript技巧
-
用js实现计算代码行数的简单方法附代码_javascript技巧
-
用js判断是否为360浏览器的实现代码_javascript技巧
-
用js实现键盘方向键翻页功能的代码_javascript技巧
-
js实现键盘操作实现div的移动或改变的原理及代码_javascript技巧
-
用js实现输入提示(自动完成)的实例代码_javascript技巧
-
Js实现网页键盘控制翻页的方法_javascript技巧
-
js实现键盘操作实现div的移动或改变的原理及代码_javascript技巧
-
用JS操作FRAME中的IFRAME及其内容的实现代码_javascript技巧
-
用js实现小球的*移动代码_javascript技巧