background
|
|
Games
Ruffnecks Gaming
Gaming for everyone
More icon

Linux
Linux Support
A small area on the internet for Linux Support.
More icon
|
|
Up Image
Navigation
Search this Site
Enter your search terms

Site Breadcrumb - You are here
|
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.

Cut, paste, and enjoy!