用javascript测试图片重合或是吻合:在屏幕的两个不同的位置显示两张相同的图片,当用鼠标左键选中某一张图片并且拖动它放到另外的一张图片的上面时,显示正确的结果(实现了相同图片的重合);否则两张图片不重合。
不知道有什么函数或是其他的方法做到检验图片是否重合或是吻合。
请高手指点一下下,谢谢!
不知道有什么函数或是其他的方法做到检验图片是否重合或是吻合。
请高手指点一下下,谢谢!
解决方案 »
- js将页面table导出excel,如何弹出保存对话框?
- window.prompt 的问题
- 高高手请帮忙: 请问如何在js里面写关闭一个网页, 得到关闭网页的确切时间.
- 请问这个函数该怎么写
- 金山的注册页面 不用提交可以检验 用户id是否被注册。。。里面有网站连接,谁帮我看看谢谢啊?要是知道告诉我,这是javascript的那方面的
- 请问newWindow.document.execCommand('saveas',....)如何限制弹出的对话框只能是htm格式,不能选择txt格式?
- mouseover 事务!求解
- 还是JAVASCRIP调用JAVA CLASS的问题
- 如何去掉控件上的事件
- 请问,我想在做一个当用户点击一个按钮时弹出一个输入框写密码。当用户输入时,它的输入框中显示"*"。应如何做啊??
- 为什么只能求当前日期的上1天(相减),而不能求下1天(用加法就出错)???
- 用DREAMWEAVER+ACCESS怎么做搜索页
img1.width==img2.width &&
img1.height==img2.height){
alert('重合');
}
if(img1.src==img2.src &&
img1.width==img2.width &&
img1.height==img2.height){
alert('重合');
}
希望高人多给小弟指点指点,谢谢了
有分的哦
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档 </title>
</head>
<script language="javascript">
var i=1;
function playImg1()
{
image1.style.filter="progid:DXImageTransform.Microsoft.BasicImage( Rotation="+i+")";
i++;
if (i>4)
{i=1};
<!--mytimeout=setTimeout("playImg()",1500);-->
}
</script> <script language="javascript">
var i=1;
function playImg2()
{
image2.style.filter="progid:DXImageTransform.Microsoft.BasicImage( Rotation="+i+")";
i++;
if (i>4)
{i=1};
<!--mytimeout=setTimeout("playImg()",1500);-->
}
</script> <script language="javascript">
var i=1;
function playImg3()
{
image3.style.filter="progid:DXImageTransform.Microsoft.BasicImage( Rotation="+i+")";
i++;
if (i>4)
{i=1};
<!--mytimeout=setTimeout("playImg()",1500);-->
}
</script> <script language="javascript">
var i=1;
function playImg4()
{
image4.style.filter="progid:DXImageTransform.Microsoft.BasicImage( Rotation="+i+")";
i++;
if (i>4)
{i=1};
<!--mytimeout=setTimeout("playImg()",1500);-->
}
</script>
<body oncontextmenu="return false">
<style>
<!--.drag{position:relative;cursor:hand}
-->
</style>
<script language="JavaScript">
var dragapproved=false
var z,x,y
function move(){
if (event.button==1&&dragapproved){
z.style.pixelLeft=temp1+event.clientX-x
z.style.pixelTop=temp2+event.clientY-y
return false
}}
function drags(){
if (!document.all)
return
if (event.srcElement.className=="drag"){
dragapproved=true
z=event.srcElement
temp1=z.style.pixelLeft
temp2=z.style.pixelTop
x=event.clientX
y=event.clientY
document.onmousemove=move
}}
document.onmousedown=drags
document.onmouseup=new Function("dragapproved=false")
</script>
<img src="picture/1.gif" name="image1" class="drag" height="150" width="150" oncontextmenu="playImg1()">
<img src="picture/2.gif" name="image2" class="drag" height="150" width="150" oncontextmenu="playImg2()">
<img src="picture/3.gif" name="image3" class="drag" height="150" width="150" oncontextmenu="playImg3()">
<img src="picture/4.gif" name="image4" class="drag" height="150" width="150" oncontextmenu="playImg4()">
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档 </title>
</head>
<script language="javascript">
var i=1;
function playImg1()
{
image1.style.filter="progid:DXImageTransform.Microsoft.BasicImage( Rotation="+i+")";
i++;
if (i>4)
{i=1};
<!--mytimeout=setTimeout("playImg()",1500);-->
}
</script> <script language="javascript">
var i=1;
function playImg2()
{
image2.style.filter="progid:DXImageTransform.Microsoft.BasicImage( Rotation="+i+")";
i++;
if (i>4)
{i=1};
<!--mytimeout=setTimeout("playImg()",1500);-->
}
</script> <script language="javascript">
var i=1;
function playImg3()
{
image3.style.filter="progid:DXImageTransform.Microsoft.BasicImage( Rotation="+i+")";
i++;
if (i>4)
{i=1};
<!--mytimeout=setTimeout("playImg()",1500);-->
}
</script> <script language="javascript">
var i=1;
function playImg4()
{
image4.style.filter="progid:DXImageTransform.Microsoft.BasicImage( Rotation="+i+")";
i++;
if (i>4)
{i=1};
<!--mytimeout=setTimeout("playImg()",1500);-->
}
</script>
<body oncontextmenu="return false">
<style>
<!--.drag{position:relative;cursor:hand}
-->
</style>
<script language="JavaScript">
var dragapproved=false
var z,x,y
function move(){
if (event.button==1&&dragapproved){
z.style.pixelLeft=temp1+event.clientX-x
z.style.pixelTop=temp2+event.clientY-y
return false
}}
function drags(){
if (!document.all||event.button!=1)
return
if (event.srcElement.className=="drag"){
dragapproved=true
z=event.srcElement
temp1=z.style.pixelLeft
temp2=z.style.pixelTop
x=event.clientX
y=event.clientY
z.style.zIndex=100;
document.onmousemove=move
}}
document.onmousedown=drags
document.onmouseup=function()
{
if(dragapproved)//存在移动时
{
if(!document.all)return;
var tag=z;
var num=parseInt(tag.name.replace("image","")); var obj;
for(var i=1;i<=4;i++)
{
if(i==num)continue;
obj=document.getElementsByName("image"+i)[0];
if(!obj)continue;
if((obj.offsetLeft==tag.offsetLeft)&&(tag.offsetTop==obj.offsetTop)&&(tag.style.filter==obj.style.filter))
alert(obj.name+"和"+tag.name+"重合!");
}
}
dragapproved=false;
}//new Function("dragapproved=false")
</script>
<img src="picture/1.gif" name="image1" alt="image1" style="filter:progid:DXImageTransform.Microsoft.BasicImage(Rotation=4)" class="drag" height="150" width="150" oncontextmenu="playImg1()">
<img src="picture/2.gif" name="image2" alt="image2" style="filter:progid:DXImageTransform.Microsoft.BasicImage(Rotation=4)" class="drag" height="150" width="150" oncontextmenu="playImg2()">
<img src="picture/3.gif" name="image3" alt="image3" style="filter:progid:DXImageTransform.Microsoft.BasicImage(Rotation=4)" class="drag" height="150" width="150" oncontextmenu="playImg3()">
<img src="picture/4.gif" name="image4" alt="image4" style="filter:progid:DXImageTransform.Microsoft.BasicImage(Rotation=4)" class="drag" height="150" width="150" oncontextmenu="playImg4()">
</body>
</html>