如何实现在IE内一张尺寸超过IE窗口的图片,鼠标在图上可以拖动图片查看,相当于IE滚动条功能。
解决方案 »
- 问一下<script id=datasearch></script>是什么意思?
- 那位大哥玩过google地图API的快救救我吧~~图标加载问题~呜呜
- google map 上面如何画框?效果类似www.woxiangyougejia.com
- ie6下关于select控件focus和disabled的问题
- JS字符串问题
- js对cookies操作的问题
- 动态修改css
- 关于自动生成表单数据问题
- ━━━━━━━ WinXP下如何使IE5.0与IE6.0共存呢? ━━━━━━━
- 有誰能幫忙將這兩個函數改成netscape下面可以使用,先謝謝了!!
- 请问校内或开心网的新提醒功能是怎么做的
- 问个查看网页js源码的问题
<img scr="test.jpg" width ='2000' heigth='3000'
即可
<!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">
html, body{
margin:0px; padding:0px;
}
#container{
overflow:hidden; position:relative;
}
#img {
display:none; position:absolute; cursor:move;
}
</style>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
window.onload = function(){
var con = $("container"), img = $("img"), x, y , isMove = false;
var width = document.body.clientWidth || document.documentElement.clientWidth,
height = document.body.clientHeight || document.documentElement.clientHeight;
con.style.width = width+ "px";
con.style.height = height + "px";
img.style.display = "block";
img.style.left = "0px";
img.style.top = "0px";
img.onmousedown = function(oEvent){
isMove = true;
oEvent = oEvent || window.event;
document.all && img.setCapture();
x = oEvent.clientX;
y = oEvent.clientY;
};
img.onmousemove = function(oEvent){
if(!isMove) return;
oEvent = oEvent || window.event;
var mx = parseInt(img.style.left) + oEvent.clientX - x;
var my = parseInt(img.style.top) + oEvent.clientY - y;
mx = Math.max(Math.min(0, mx), width - img.width);
my = Math.max(Math.min(0, my), height - img.height);
img.style.left = mx + "px";
img.style.top = my + "px";
x = oEvent.clientX;
y = oEvent.clientY;
document.title = mx + " " + my;
};
img.onmouseup = function(){
isMove = false;
document.all && img.releaseCapture();
};
};
</script>
</head>
<body>
<div id="container">
<img id="img" src="http://travel.dahangzhou.com/fengjing/347/pics/20071025164439994.jpg" />
</div>
</body>
</html>
这句中的document.all &&是做什么用的?
这里为什么还会有个oEvent?
看MSDN上面似乎没有这个参数,而且貌似也是多余的。
莫非是兼容其他浏览器用的?
麻辣隔壁的,原来document.all && img.setCapture();也是兼容浏览器的。
查了查setCapture,原来是IE Only,在js中&&前面的条件为false的话是不会执行后面的条件语句的,例如:
alert(true && alert(1) );
把true换成false后就只执行一次alert(false);而在true下时会弹出两次。狗日的浏览器,狗日的W3C.
祝Microsoft千秋万载,一统糨糊!