-
Senior Member
- Rep Power
- 223
- Reputation
- 171
Firefox alternative to IE FireEvent?
Hi guys
I have a basic website for a small footy tipping comp I run that I originally designed for IE. I'm now trying to make it work with the other popular browsers, namely Firefox.
A couple of pages use the IE "FireEvent" method under Javascript but FF doesn't like this.
Here is the line of code that fails with FF:
document.getElementById('rdo_HomeTeam').fireEvent( 'onmouseover');
Basically, the above code emulates a mouseover event on a radio button (with the radio button having it's own event assigned to it).
I found this but not sure how to modify it for my situation.
<head>
<script type="text/javascript">
function InitClick (event) {
if (event.initMouseEvent) { // all browsers except IE before version 9
var clickEvent = document.createEvent ("MouseEvent");
clickEvent.initMouseEvent ("click", true, true, window, 0,
event.screenX, event.screenY, event.clientX, event.clientY,
event.ctrlKey, event.altKey, event.shiftKey, event.metaKey,
0, null);
event.target.dispatchEvent (clickEvent);
} else {
if (document.createEventObject) { // IE before version 9
var clickEvent = document.createEventObject (window.event);
clickEvent.button = 1; // left click
event.srcElement.fireEvent ("onclick", clickEvent);
}
}
}
</script>
</head>
<body>
<input type="checkbox" onmouseover="InitClick (event);" onclick="alert ('click event occurred')"/>Hover over the check box!
</body>
Any help would be appreciated.
Last edited by AussieM8; 28-07-11 at 01:46 AM.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks