你都有地址了,把地址的代码拿下来参考即可,它是用js计算的,没有覆盖div<a href="http://news.ifeng.com/photo/yizhousaojietu/detail_2011_12/25/11555699_0.shtml" id="bigLink" style="cursor: url(http://img.ifeng.com/tres/TemplateRes/left.cur), auto; "><img onmousemove="imageonmousemove(event)" id="bigImage" src="http://res.news.ifeng.com/b52d6dcee929704a/2011/1218/rdn_4eed27916c965.jpg" width="950" height="600" alt="一周扫街图2011.12.11-12.17 " title="<<点击浏览上一张"></a>
<script>
prevLink = "http://news.ifeng.com/photo/yizhousaojietu/detail_2011_12/25/11555699_0.shtml";
nextLink = "http://news.ifeng.com/photo/yizhousaojietu/detail_2011_12/18/11399277_1.shtml"; function $(id){return document.getElementById(id);} function getpos(element) {
if (arguments.length != 1 || element == null) {
return null;
}
var elmt = element;
var offsetTop = elmt.offsetTop;
var offsetLeft = elmt.offsetLeft;
var offsetWidth = elmt.offsetWidth;
var offsetHeight = elmt.offsetHeight;
while (elmt = elmt.offsetParent) {
if (elmt.style.position == 'absolute' || (elmt.style.overflow != 'visible' && elmt.style.overflow != '')) {
break;
}
offsetTop += elmt.offsetTop;
offsetLeft += elmt.offsetLeft;
}
return {
top: offsetTop,
left: offsetLeft,
right: offsetWidth + offsetLeft,
bottom: offsetHeight + offsetTop
};
} function imageonmousemove(evnt) {
var photopos = getpos($("bigImage"));
if (evnt) {
nx = (parseInt(evnt.clientX) - photopos.left) / $("bigImage").width;
if (nx > 0.5 && nextLink != "") {
if($("bigLink").style.cursor.toString().indexOf("left")!=-1||!$("bigLink").style.cursor){
$("bigLink").style.cursor = "url(http://img.ifeng.com/tres/TemplateRes/right.cur),auto";
}
$("bigImage").title = "点击浏览下一张>>";
$("bigLink").href = nextLink;
}
if (nx <= 0.5 && prevLink != "") {
if($("bigLink").style.cursor.toString().indexOf("right")!=-1||!$("bigLink").style.cursor){
$("bigLink").style.cursor = "url(http://img.ifeng.com/tres/TemplateRes/left.cur),auto";
}
$("bigImage").title = "<<点击浏览上一张";
$("bigLink").href = prevLink;
}
}
}</script>
<script>
prevLink = "http://news.ifeng.com/photo/yizhousaojietu/detail_2011_12/25/11555699_0.shtml";
nextLink = "http://news.ifeng.com/photo/yizhousaojietu/detail_2011_12/18/11399277_1.shtml"; function $(id){return document.getElementById(id);} function getpos(element) {
if (arguments.length != 1 || element == null) {
return null;
}
var elmt = element;
var offsetTop = elmt.offsetTop;
var offsetLeft = elmt.offsetLeft;
var offsetWidth = elmt.offsetWidth;
var offsetHeight = elmt.offsetHeight;
while (elmt = elmt.offsetParent) {
if (elmt.style.position == 'absolute' || (elmt.style.overflow != 'visible' && elmt.style.overflow != '')) {
break;
}
offsetTop += elmt.offsetTop;
offsetLeft += elmt.offsetLeft;
}
return {
top: offsetTop,
left: offsetLeft,
right: offsetWidth + offsetLeft,
bottom: offsetHeight + offsetTop
};
} function imageonmousemove(evnt) {
var photopos = getpos($("bigImage"));
if (evnt) {
nx = (parseInt(evnt.clientX) - photopos.left) / $("bigImage").width;
if (nx > 0.5 && nextLink != "") {
if($("bigLink").style.cursor.toString().indexOf("left")!=-1||!$("bigLink").style.cursor){
$("bigLink").style.cursor = "url(http://img.ifeng.com/tres/TemplateRes/right.cur),auto";
}
$("bigImage").title = "点击浏览下一张>>";
$("bigLink").href = nextLink;
}
if (nx <= 0.5 && prevLink != "") {
if($("bigLink").style.cursor.toString().indexOf("right")!=-1||!$("bigLink").style.cursor){
$("bigLink").style.cursor = "url(http://img.ifeng.com/tres/TemplateRes/left.cur),auto";
}
$("bigImage").title = "<<点击浏览上一张";
$("bigLink").href = prevLink;
}
}
}</script>
解决方案 »
- var id = $("#<%=ServerID.ClientID%>").val();无法获取值
- 用JS写的 Flash在FF不显示,IE正常
- 我自定义类想继承Array类,请问apply加new Array()方法怎么不行啊?
- EXT/Ajax学习及技术交流活动
- ,小弟要实现的功能如上,能否通过判断IE的字符集来进行跳转,例如是"GB2312"进中文的网站,"UTF-8"进"英文"的网站
- 如何用JAVASCRIPT获取当前窗口的高度和宽度?
- 想做一个既可输入又可选择的Combox,高手请进,在线等待,急!!!!!!!!!!!
- jquery.easyui的一个问题,请各位帮忙!
- 如何在静态网页中逐个显示连续编号的N个FLASH文件
- calendar.js日期控件在jsp页面如何使用呢???急求答案
- 谁有比较好的javascript视频教程啊
- 这样一个眼镜特效是不是用js做的?、、
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>图片左右分别链接</title>
</head>
<style type="text/css">
#pic{ margin:0 auto; text-align:center; position:relative; width:800px; height:600px;}
#left{ left:0; width:400px; height:600px; position:absolute;}
#right{right:0; width:400px; height:600px; position:absolute;}
</style>
<body>
<div id="pic">
<a href="#" id="left"></a>
<a href="#" id="right"></a>
<img src="images/Winter.jpg" width="800" height="600">
</div>
<script type="text/javascript">
function imgLink(){
var divBox = document.getElementById("pic");
var getLeft = document.getElementById("left");
var getRight = document.getElementById("right")
var divPic = divBox.getElementsByTagName("img")[0];
var picW = divPic.getAttribute("width");
var picH = divPic.getAttribute("height");
if(picW==null&&picH==null){
alert("图片默认尺寸未填写!");
return false;
}
//getLeft.style.setAttribute("width",Math.floor(picW/2)+"px");
getLeft.style.width = getRight.style.width = Math.floor(picW/2)+"px";
getLeft.style.height = getRight.style.height = picH+"px";
divBox.style.width = picW + "px";
getLeft.setAttribute("href","http://www.baidu.com")
getRight.setAttribute("href","http://www.sina.com.cn")
}
window.onload = imgLink();
</script>
</body>
</html>
我一看就知道二楼是正确的.并且实现了一下,OK了 ,正确了,实现了
演示网址
http://www.wenyifan.net/images/details/25.html