Webmonkey
Powered by Atomz.com



Quick Reference:

• Javascript Code Library
HTML Cheatsheet
Special Characters
Color Codes
Browser Chart
Stylesheet Guide
Unix Guide
Glossary
Domain Registries

Reference   JavaScript Code Library

When an event occurs, both Netscape 4 and Internet Explorer 4 register the cursor's position. IE 4 stores the position on the globally-accessible window.event object, but unfortunately Netscape does not. This code captures the cursor position for Netscape 4 when a mouse event fires and creates an IE 4-style window.event object to store the position.

Usage: Copy and paste the code into your document. Then whenever one of the captured events fires, you will be able to use window.event.x, window.event.y, window.event.screenX, window.event.screenY, window.event.clientX and window.event.clientY in both Netscape 4 and IE 4.

Usage notes:
You can specify which events capture the cursor's position by editing the code. You will need to do two things to add an event:

  1. Add the desired event to the following line:
    window.captureEvents(Event.MOUSEOVER|Event.MOUSEOUT|Event.CLICK|Event.DBLCLICK);
  2. Add a new line similar to this:
    window.onclick = WM_getCursorHandler;
    where "onclick" should be changed to the corresponding event handler for your new event.

License: Webmonkey Public License

Cut, paste, and enjoy!


Feedback  |  Help  |  About Us  |  Contribute  |  Jobs
Advertise  |  Privacy Statement  |  Terms and Conditions

Copyright © 1994-2000 Wired Digital Inc., a Lycos Network site. All rights reserved.