Ik heb het volgende javascript:

<script language="JavaScript1.2">

<!-- Voor de leukste scripts gaat u naar...-->
<!-- Sentinelli’s Javascript! The source for all your Javascript and PHP -->
<!-- http://www.sentinelli.nl -->


function test(){
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else { // grab the x-y pos.s if browser is NS
tempX = e.pageX;
tempY = e.pageY;
}
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}
document.Show.MouseX.value = tempX;
document.Show.MouseY.value = tempY;
return true;
}
}
// End -->
</script>

Nu wil ik dat deze coordinaten alleen gelden voor een afbeelding en niet voor een hele pagina... iemand een idee?
Dit was trouwens het vorige script:

<?php
	ini_set ('display_errors', 1);
	error_reporting (E_ALL);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<title>mouse postion on image</title>
</head>

<body>
	<form id="myform" method="post" action="#">
		
		<p><input type="image" src="tropical-bird.jpg"></p>
		<?php
			if (isset ($_POST['x']) && $_POST['y']) {
				echo '<p><label for="x">x:</label><input id="x" name="x" type="text" value="' . $_POST['x'] . '"</p>';
				echo '<p><label for="y">y:</label><input id="y" name="y" type="text" value="' . $_POST['y'] . '"</p>';
			}
		?>	
	</form>
</body>
</html>
WHOEEEHOOOOEOEEE
eindelijk hij doet het na half weekje zoeken dankjee(k):D

Reageren