Hello!
This following script is working as standalone but it causes conflict in combination with other script. To avoid this problem i would like to intergreate the output line:
window.status = offsets.x + ‘:’ + offsets.y;
into the inside of <script></script>
For example:
///////////////////
<script>
….
window.status = offsets.x + ‘:’ + offsets.y;
</script>
<image src=”test.jpg” onmousemove=”getOffsets(event, this);”>
///////////////////
How can i do it? sorry for my bad english!!! Thank you!
[code=php]<html>
<head>
<title>
offsetX/offsetY
</title>
<script type=”text/javascript”>
function getPageCoords (element) {
var coords = {x: 0, y: 0};
while (element) {
coords.x += element.offsetLeft;
coords.y += element.offsetTop;
element = element.offsetParent;
}
return coords;
}
function getOffsets (evt) {
if (typeof evt.offsetX != ‘undefined’)
return { x: evt.offsetX, y: evt.offsetY }
else if (evt.target) {
if (window.opera)
var element = evt.target;
else
var element = evt.target.nodeType == 1 ? evt.target :
evt.target.parentNode;
var eventCoords = {
x: evt.clientX + window.pageXOffset,
y: evt.clientY + window.pageYOffset
};
var elCoords = getPageCoords(element);
return {x: eventCoords.x – elCoords.x, y: eventCoords.y –
elCoords.y};
}
}
</script>
</head>
<body>
<image src=”test.jpg” onmousemove=”var offsets = getOffsets(event);
window.status = offsets.x + ‘:’ + offsets.y;”>
</body>
</html>