From: Pierre G. <p_g...@ho...> - 2004-03-11 10:59:02
|
Here is my problem. I need to locate the mouse events (move, down, up) in a layer that is in a relative position. To do that I have a <div> layer in my document. I create a DynLayer equal to the first one with getInline(). Then I get the mouse events to return the mouse coordinates values relatively to the layer. My problem is that I don't get the same results on different browser. In Netscape 7.1, Mozilla 1.5, Mozilla 1.00 it seems to works perfectly. But in IE 6.0, Netscape 4.77, the results seem to take reference to the top left of the whole document. Have a quick look at : http://pierre.giraud3.free.fr/divers/mapsurfer/javascript/dynapi3x/essais/dynapi.api.dynlayer-mouseevents.html Does someone have reasons for that ? Thanks Here is my code : ******************************* moveevents.onmousemove = function(e) { document.myform.movex.value = e.x document.myform.movey.value = e.y return false } var upevents = {}; upevents.onmouseup = function(e) { document.myform.upx.value = e.x document.myform.upy.value = e.y return false } dynapi.onLoad(init); function init() { // get the div layer in the HTML code (require DynLayerInline library) mylayer = DynLayer.getInline("container"); //mylayer.setPosition('absolute'); mylayer.captureMouseEvents(); mylayer.addEventListener(downevents) mylayer.addEventListener(moveevents) mylayer.addEventListener(upevents) } </script> </head> <body bgcolor="#999999"> un peu de texte<br> <form name="myform"> <table border=0 bgcolor='pink'> <tr> <td></td> <td>Down</td> <td>Move</td> <td>Up</td> </tr> <tr> <td>X</td> <td><input type="text" name="downx" size=3></td> <td><input type="text" name="movex" size=3></td> <td><input type="text" name="upx" size=3></td> </tr> <tr> <td>Y</td> <td><input type="text" name="downy" size=3></td> <td><input type="text" name="movey" size=10></td> <td><input type="text" name="upy" size=3></td> </tr> </table> </form> <table border=1 cellspacing=5 cellpadding=0> <tr> <td>un texte à gauche</td> <td><div id="container" style="position:relative"><img src="../../../tmp/1078753886104361.png"></div></td> </tr> </table> </body> </html> ************************************* _________________________________________________________________ MSN Messenger http://g.msn.fr/FR1001/866 : un logiciel gratuit pour dialoguer avec vos amis ! |