全球主机交流论坛
标题:
键盘左右键控制翻页到底怎么弄!
[打印本页]
作者:
云生
时间:
2012-6-11 17:17
标题:
键盘左右键控制翻页到底怎么弄!
本帖最后由 云生 于 2012-6-11 21:06 编辑
很久以前就想实现这个功能了。一直学不会。
网上看到这段代码,但还是不会。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>上一页下一页地址</title>
<style type="text/css">
#new_b{
display: none;
}
#pre{
height: 50px;
width: 400px;
background-color:#dedede;
}
#next{
height: 50px;
width: 400px;
background-color:#dedede;
}
</style>
</head>
<body>
<div id="new_b">
总数:<a title="Total record"> <b>16</b> </a> <a href="/xinwen/index.html">首页</a> <a href="http://www.baidu.com">上一页</a> <a href="/xinwen/index.html">1</a> <b>2</b> <a href="/xinwen/index_3.html">3</a> <a href="/xinwen/index_4.html">4</a> <a href="/xinwen/index_3.html">下一页</a> <a href="/xinwen/index_4.html">尾页</a>
</div>
本文件向你展示如果获取帝国CMS上一页下一页的地址:<br />
上一页的地址是:<br />
<div id="pre"></div>
下一页的地址是:<br />
<div id="next"></div>
<a href="#" id="p">上一页</a> <a href="#" id="n">上一页</a>
<br /><br /><br /><br /><br />
*************************************云客yunke原创 云游天下 做客四方 qq:1012574684 *************************************
<script type="text/javascript">
var str;
var pre;
var next;
str=document.getElementById("new_b").innerHTML;
var preex;
var nextex;
preex='[A-Za-z0-9_\./:]+(?=">上一页)';
//preex='[\w\.]+(?=">上一页)'; 注意js不支持此写法
nextex='[A-Za-z0-9_\./:]+(?=">下一页)';
pre=str.match(preex);
next=str.match(nextex);
document.getElementById("pre").innerHTML=pre;
document.getElementById("next").innerHTML=next;
alert(pre[0]);
// alert(next[0]);
if(pre!=null)
{
document.getElementById("p").href=pre;
}
if(next!=null)
{
document.getElementById("n").href=next;
}
</script>
</body>
</html>
复制代码
作者:
iyuheng
时间:
2012-6-11 17:20
我也不会
作者:
iking
时间:
2012-6-11 17:26
js还挺复杂
作者:
否要
时间:
2012-6-11 17:33
看不来。不过觉得这是DIV+css实现的吧,或许html+css3效果会更好
作者:
GameOver
时间:
2012-6-11 17:35
我也不会
作者:
atrong
时间:
2012-6-11 17:39
不会
作者:
wdlth
时间:
2012-6-11 18:19
js,鼠标事件。
作者:
云生
时间:
2012-6-11 19:42
就没人会吗?
作者:
micto
时间:
2012-6-11 20:52
<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312" />
<title>上一页下一页测试</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(document).click(function(e){
var prevUrl = $('.prev').attr('href');
if (e.which == 0 || e.which == 1) {
window.location.href = prevUrl;
}
});
$(document).bind("contextmenu",function(){
var nextUrl = $('.next').attr('href');
window.location.href = nextUrl;
});
});
</script>
</head>
<body>
<footer id="footer">
<div class="pager">
<a href="http://www.163.com" class="prev">上一页</a>
<a href="http://www.google.com" class="next">下一页</a>
</div>
</footer>
</body>
</html>
复制代码
另外,楼主在武汉读的大学?
欢迎光临 全球主机交流论坛 (https://sunk.eu.org/)
Powered by Discuz! X3.4