Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1423 How can I move an image to where I click on the browser window?

You are here: irt.org | FAQ | DHTML | Q1423 [ previous next ]

Try:

<html>
<head>
<script language="JavaScript"><!--
if (document.layers) {
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown = myDown;
}

function myDown(e) {
    if (document.layers) {
         document.layers['x'].left = e.screenX - window.screenX - (window.outerWidth - window.innerWidth);
         document.layers['x'].top = e.screenY - window.screenY - (window.outerHeight - window.innerHeight) + 25;
    }
    else if (document.all) {
        document.all('x').style.posLeft = window.event.x;
        document.all('x').style.posTop = window.event.y;
    }
}
//--></script>
</head>

<body onMouseDown="myDcroll()">

<div id="x" style="position:absolute;"><img src="image.gif" height="100" width="100"></div>

</body>
</html>

Feedback on 'Q1423 How can I move an image to where I click on the browser window?'

©2018 Martin Webb