Finding Screen Location in DHTML


Location x : y :


The code is as shown below.

<HEAD>

<TITLE>Finding Screen Location</TITLE>

<SCRIPT LANGUAGE="JavaScript" SRC="../include/browser.js"></SCRIPT>

<SCRIPT LANGUAGE="JavaScript">

function locate (evnt)
{
	if (isNS4 || isIE4)
	{
		if (isNS4)
		{
			topVal = eval(evnt.pageY);
			leftVal = eval(evnt.PageX);
		}
		else
		{
			topVal = eval(evnt.y);
			leftVal = eval(evnt.x);
		}
	}
	document.coords.xcoord.value = leftVal;
	document.coords.ycoord.value = topVal;
}

function nodda () { null; }

</SCRIPT>

</HEAD>

<BODY>

<A HREF="../dhtmlidx.html">Dynamic HTML Index</A><BR><BR>

<P>
	<FORM ACTION="test" METHOD="get" NAME="coords">
		Location x : <INPUT TYPE="text" NAME="xcoord" SIZE="3">
		y : <INPUT TYPE="text" NAME="ycoord" SIZE="3">
	</FORM>
</P>

<A HREF="#" onClick="nodda();locate(event);">
	<IMG SRC="../graphics/TheFightingTemeraire.jpg">
</A>