Hi all,
I am using Firefox and embedding Javascript in html. I understand that
we can use mouse events by coding them in the body of html (by creating
a button or anything and by adding in the events in the <img> tag).
[code]
<input id="StdDev Value" name="StdDevBut ton" type="button"
value="Standard Deviation Value" onclick="readSt dDevValue()"/>
But what if I need to add some mouse events without creating any img or
button? What I mean is - when the mouse cursor is in certain coordinates
(eg. in certain areas on an image), then if the user left click,
something will happen. The beloow example code seems to be not working
for me....
<html>
<head>
<script language="javas cript">
document.addEve ntListener("mou semove", calculatePos, false);
function init() {
}
function getMousePositio n(event) {
var posX = 0;
var posY = 0;
posX = event.clientX + document.body.s crollLeft;
posY = event.clientY + document.body.s crollTop;
var position = new Array(2);
position[0] = posX;
position[1] = posY;
return position;
}
function calculatePos (event) {
var mousePosition = getMousePositio n(event);
checkAreaIn(mou sePosition);
}
function checkAreaIn(mou sePosition) {
var mx = mousePosition[0];
var my = mousePosition[1];
window.status = "X= " + mx + " Y= " + my;
if (mx > 20 && mx < 80 && my > 40 && my < 100) {
this.onclick = "pop()";
} else {
}
}
function pop() {
alert("working! !!");
}
</script>
</head>
<body onload="init(); ">
</body>
</html>
Could anyone tell me how could I do it, please?
Thanks in advance.
seanky
*** Sent via Developersdex http://www.developersd ex.com ***
Comment