Eventful JavaScript Wednesday evening, 6 July 2005
In fixing an existing script I came across the need to determine what event fired the script. The case was a roll over which used the same function to swap the image source (applied to both mouseover and mouseout). The problem was if the mouse was over the image while it loaded, the image roll over got stuck back to front!
It took me a while to figure out how to get it going so I could use a single event object in both Internet Explorer and Firefox flavours of browsers so I thought I'd share the ultimately fairly simple fix with you
function someFunction(e) { if(!e) { e = event; } // do stuff with e // etc etc }
The event object 'e' can now be used in any modern browser, enjoy!
Comments
Get Around
Journal
- contemplating.Thoughts from a Christian world-view.
- enjoying.Reviews of stuff i've been enjoying.
- life.For those that would like to know what i'm up to, this is the place to look.
- working.Thoughts and ideas on web development and projects i'm working on.
Other Places
- Flickr. Home of my photos.
- Artykins. My fiancé’s blog.
- HydeStreetChapel.org. My church.