<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
#pic {
height: 300px;
width: 420px;
border: 3px solid #ccc;
background-image: url(http://www.happyshow.org/sample/20060619/3.jpg);
background-repeat: no-repeat;
background-position: 0px 0px;
background-color: #333;
cursor: crosshair;
}
-->
</style>
<script type="text/javascript">
<!--
var p = new Array();
var speed = 1.0; // 1 表示1倍速度,即原速
var x,y // 鼠标点下去时背景的坐标
var x_new,y_new //位移
function getmouseposition(event)
{
if(document.all)
{
x = document.body.scrollLeft+event.clientX;
y = document.body.scrollTop+event.clientY;
}else
{
x = event.layerX;
y = event.layerY;
}
}
function setmouseposition(event)
{
if(document.getElementById('pic').style.backgroundPosition.length==0)
{document.getElementById('pic').style.backgroundPosition="0px 0px";}
p = document.getElementById('pic').style.backgroundPosition.split(" ")
if(document.all)
{
x_new = document.body.scrollLeft+event.clientX;
y_new = document.body.scrollTop+event.clientY;
}else
{
x_new = event.layerX;
y_new = event.layerY;
}
x2 = (speed*(x_new-x)+parseInt(p[0])).toString(10); // 计算位移量
y2 = (speed*(y_new-y)+parseInt(p[1])).toString(10);
document.getElementById('pic').style.backgroundPosition=x2+"px "+y2+"px";
}
-->
</script>
</head>
<body>
<div id="pic" onmousedown="getmouseposition(event)" onmouseup="setmouseposition(event)"></div>
今天在玩 google earth 4.0b,发现 Print Screen 下来的图片很大,如果直接放在网页上,因为尺寸太大又不合适,又不想压缩图片的尺寸,于是乎就想到了这种方法,没想到实现起来比预想的要容易。呵呵,该死的是,这段代码还兼容 firefox。
</body>
</html>
今天在玩 google earth 4.0b,发现 Print Screen 下来的图片很大,如果放在网页不合适,又不想压缩图片的尺寸,于是乎就想到了这种方法,没想到实现起来比预想的要容易。呵呵,该死的是,这段代码还兼容 firefox。
--------------------------------------------------------------------------------------
2006.6.20 修改:
·添加了滚动的范围,不会出现背景
·用到onmousemove事件,图片实时随鼠标移动而移动
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
#pic {
width:420px;
height:300px;
border: 3px solid #ccc;
background-image: url(http://www.happyshow.org/sample/20060619/3.jpg);
background-repeat: no-repeat;
background-position: 0px 0px;
cursor: move;
}
-->
</style>
<script type="text/javascript">
<!--
var p = new Array();
var speed = 0.05; //速度
var picWidth = 1280; // 大图的宽高
var picHeight = 971;
var x,y // 鼠标点下去时背景的坐标
var x_new,y_new //位移
var haveclick = false;
function getmouseposition(event)
{
if(document.all)
{
x = document.body.scrollLeft+event.clientX;
y = document.body.scrollTop+event.clientY;
}else
{
x = event.layerX;
y = event.layerY;
}
haveclick = true;
}
function movestop()
{
haveclick = false;
}
function movestart(event)
{
if(haveclick)
{
if(document.getElementById('pic').style.backgroundPosition.length==0)
{document.getElementById('pic').style.backgroundPosition="0px 0px";}
p = document.getElementById('pic').style.backgroundPosition.split(" ")
if(document.all)
{
x_new = document.body.scrollLeft+event.clientX;
y_new = document.body.scrollTop+event.clientY;
}else
{
x_new = event.layerX;
y_new = event.layerY;
}
x2 = (speed*(x_new-x)+parseInt(p[0])).toString(10); // 计算位移量
y2 = (speed*(y_new-y)+parseInt(p[1])).toString(10);
if (x2<-picWidth+420) x2=-picWidth+420;
if (y2>0) y2=0;
if (x2>0) x2=0;
if (y2<-picHeight+300) y2=-picHeight+300;
document.getElementById('pic').style.backgroundPosition=x2+"px "+y2+"px";
}
}
-->
</script>
</head>
<body>
<div id="pic" onmousedown="getmouseposition(event)" onmousemove="movestart(event)" onmouseup="movestop()" onmouseout="movestop()"> </div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
#pic {
height: 300px;
width: 420px;
border: 3px solid #ccc;
background-image: url(http://www.happyshow.org/sample/20060619/3.jpg);
background-repeat: no-repeat;
background-position: 0px 0px;
background-color: #333;
cursor: crosshair;
}
-->
</style>
<script type="text/javascript">
<!--
var p = new Array();
var speed = 1.0; // 1 表示1倍速度,即原速
var x,y // 鼠标点下去时背景的坐标
var x_new,y_new //位移
function getmouseposition(event)
{
if(document.all)
{
x = document.body.scrollLeft+event.clientX;
y = document.body.scrollTop+event.clientY;
}else
{
x = event.layerX;
y = event.layerY;
}
}
function setmouseposition(event)
{
if(document.getElementById('pic').style.backgroundPosition.length==0)
{document.getElementById('pic').style.backgroundPosition="0px 0px";}
p = document.getElementById('pic').style.backgroundPosition.split(" ")
if(document.all)
{
x_new = document.body.scrollLeft+event.clientX;
y_new = document.body.scrollTop+event.clientY;
}else
{
x_new = event.layerX;
y_new = event.layerY;
}
x2 = (speed*(x_new-x)+parseInt(p[0])).toString(10); // 计算位移量
y2 = (speed*(y_new-y)+parseInt(p[1])).toString(10);
document.getElementById('pic').style.backgroundPosition=x2+"px "+y2+"px";
}
-->
</script>
</head>
<body>
<div id="pic" onmousedown="getmouseposition(event)" onmouseup="setmouseposition(event)"></div>
今天在玩 google earth 4.0b,发现 Print Screen 下来的图片很大,如果直接放在网页上,因为尺寸太大又不合适,又不想压缩图片的尺寸,于是乎就想到了这种方法,没想到实现起来比预想的要容易。呵呵,该死的是,这段代码还兼容 firefox。
</body>
</html>
今天在玩 google earth 4.0b,发现 Print Screen 下来的图片很大,如果放在网页不合适,又不想压缩图片的尺寸,于是乎就想到了这种方法,没想到实现起来比预想的要容易。呵呵,该死的是,这段代码还兼容 firefox。
--------------------------------------------------------------------------------------
2006.6.20 修改:
·添加了滚动的范围,不会出现背景
·用到onmousemove事件,图片实时随鼠标移动而移动
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
#pic {
width:420px;
height:300px;
border: 3px solid #ccc;
background-image: url(http://www.happyshow.org/sample/20060619/3.jpg);
background-repeat: no-repeat;
background-position: 0px 0px;
cursor: move;
}
-->
</style>
<script type="text/javascript">
<!--
var p = new Array();
var speed = 0.05; //速度
var picWidth = 1280; // 大图的宽高
var picHeight = 971;
var x,y // 鼠标点下去时背景的坐标
var x_new,y_new //位移
var haveclick = false;
function getmouseposition(event)
{
if(document.all)
{
x = document.body.scrollLeft+event.clientX;
y = document.body.scrollTop+event.clientY;
}else
{
x = event.layerX;
y = event.layerY;
}
haveclick = true;
}
function movestop()
{
haveclick = false;
}
function movestart(event)
{
if(haveclick)
{
if(document.getElementById('pic').style.backgroundPosition.length==0)
{document.getElementById('pic').style.backgroundPosition="0px 0px";}
p = document.getElementById('pic').style.backgroundPosition.split(" ")
if(document.all)
{
x_new = document.body.scrollLeft+event.clientX;
y_new = document.body.scrollTop+event.clientY;
}else
{
x_new = event.layerX;
y_new = event.layerY;
}
x2 = (speed*(x_new-x)+parseInt(p[0])).toString(10); // 计算位移量
y2 = (speed*(y_new-y)+parseInt(p[1])).toString(10);
if (x2<-picWidth+420) x2=-picWidth+420;
if (y2>0) y2=0;
if (x2>0) x2=0;
if (y2<-picHeight+300) y2=-picHeight+300;
document.getElementById('pic').style.backgroundPosition=x2+"px "+y2+"px";
}
}
-->
</script>
</head>
<body>
<div id="pic" onmousedown="getmouseposition(event)" onmousemove="movestart(event)" onmouseup="movestop()" onmouseout="movestop()"> </div>
</body>
</html>
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年11月15日
2024年11月15日
- 廖也欧《面朝大海》[Hi-Res][24bit 48kHz][FLAC/分轨][170.14MB]
- s13T1夺冠五人名单都有谁 s13T1夺冠五人名单一览
- 英雄联盟T1战队队长都有谁 T1战队所有队长介绍
- skt历届战队成员都有哪些 skt历届战队成员名单盘点
- 妙音唱片《大热唱片3》[WAV+CUE]
- 费玉清《跟着地球旋转》滚石时代经典复刻[正版原抓WAV+CUE]
- 罗文甄妮-射雕英雄传(AMCD)(限量版)[WAV+CUE]
- 《巫师4》定档2025再添佐证:参演人员曝光 老将回归
- 辣眼睛 美女COS《黑神话:悟空》比基尼版金池长老
- 外媒称PS5pro违背承诺:《蜘蛛侠2》根本没法4K60帧
- 令晴 Lynn《The Make》[320K/MP3][44.47MB]
- 令晴 Lynn《The Make》[Hi-Res][24bit 48kHz][FLAC/分轨][295.42MB]
- 雷婷《移情别恋HQⅡ》头版限量编号[低速原抓WAV+CUE][1G]
- FUNDAMENTAL.1989-感觉号渡轮【SONY】【WAV+CUE】
- 上山安娜.1986-上山安娜【EMI百代】【WAV+CUE】