Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] An easy one for the experts :-)
- From: javascript@xxxxxxxxxx (Matthieu Féron)
- Subject: [Javascript] An easy one for the experts :-)
- Date: Thu, 20 Dec 2001 14:35:04 +0100
for cross browser solution, don't use IE dom programming. So use a href around your image and a div to locate your image on the window. -----Message d'origine----- De : brian@xxxxxxxx [mailto:brian@xxxxxxxx] Envoy=E9 : jeudi 20 d=E9cembre 2001 16:27 =C0 : javascript@xxxxxxxxxx Objet : [Javascript] An easy one for the experts :-) Hi, I have searched the manuals .. on google .. in archives ... without luck. Consider this piece of code: <html><head><title>Test</title> <script> function position(event) { cursor.style.posLeft=3Dboard.style.posLeft+event.x; cursor.style.posTop=3Dboard.style.posTop+event.y; } </script> </head> <body> <p><img id=3D"board" width=3D"320" height=3D"320" src=3D"board.gif" style=3D"position:relative;" onClick=3D"position(event)"> <img id=3D"cursor" src=3D"cursor.gif" style=3D"position:absolute"> </body> </html> Purpose: - whenever a mouse click is detected on board move the cursor to this position. Problem: - although the code works (!) the cursor is misaligned. That is, it is positioned something like 5 pixels to the left of the click and 5 pixels above the click. I've tried to use pageXOffset and pageYOffset to adjust the cursor - but I guess they're only good when scrollbars are involved. How do I solve this? I know I can set position:absolute et al on the board, but this is not acceptable ... I'm mainly targeting IE but, if at all possible, would like to see a cross-browser solution :-) Merry Christmas, Brian _______________________________________________ Javascript mailing list Javascript@xxxxxxxxxx https://lists.LaTech.edu/mailman/listinfo/javascript
- Follow-Ups:
- [Javascript] An easy one for the experts :-)
- From: javascript@xxxxxxxxxx
- [Javascript] An easy one for the experts :-)
- Prev by Date: [Javascript] Frame re-load Question
- Next by Date: [Javascript] An easy one for the experts :-)
- Previous by thread: [Javascript] Esther Strom/McDougal/hmco is out of the office.
- Next by thread: [Javascript] An easy one for the experts :-)
- Index(es):