Results 1 to 1 of 1

Thread: Firefox alternative to IE FireEvent?

  1. #1
    Senior Member
    Join Date
    Jan 2008
    Posts
    636
    Thanks
    79
    Thanked 23 Times in 20 Posts
    Rep Power
    223
    Reputation
    171

    Default 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.



Look Here ->

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •