ABrand
08-08-2005, 04:21 AM
I'm trying to get an image to be dragable across the screen in HTML and clicking on that image will result in opening a new window (containing an image)
The code i have so far does do the draging, but i presume that the MouseDown works as a mouseclick: when you drag the image it opens the new window. Is there a way around this?
I'd also like to have an image with multiple hyperlinks that's also dragable, but i have no clue as how to make this, any suggestions??
I'm not very fluent in JS ...
Any input is much appriciated, Arjan
<head>
<style>
<!--
.drag{position:relative;cursor:hand}
-->
</style>
<script language="JavaScript1.2">
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>
</head>
<body background="Images/Graphix/beuk%20copy.jpg">
<p><img src="Images/Graphix/Logo%20Glass.jpg" width="296" height="162"></p>
<a href="DJ Booth/Club11_2.htm" target="_blank" toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=400,hei ght=300'); return false;}"><img src="Images/Foto/DSCF0045.jpg" width="297" height="223" class="drag"></a>
</body>
</html>
The code i have so far does do the draging, but i presume that the MouseDown works as a mouseclick: when you drag the image it opens the new window. Is there a way around this?
I'd also like to have an image with multiple hyperlinks that's also dragable, but i have no clue as how to make this, any suggestions??
I'm not very fluent in JS ...
Any input is much appriciated, Arjan
<head>
<style>
<!--
.drag{position:relative;cursor:hand}
-->
</style>
<script language="JavaScript1.2">
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>
</head>
<body background="Images/Graphix/beuk%20copy.jpg">
<p><img src="Images/Graphix/Logo%20Glass.jpg" width="296" height="162"></p>
<a href="DJ Booth/Club11_2.htm" target="_blank" toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=400,hei ght=300'); return false;}"><img src="Images/Foto/DSCF0045.jpg" width="297" height="223" class="drag"></a>
</body>
</html>