Results 1 to 2 of 2

Thread: mouse event in FireFox vs IE

  1. #1
    Join Date
    Oct 2012

    mouse event in FireFox vs IE

    Hi, I understand what my problem is - W3C event objects are not global but are passed to the handler, IE they are global. I've run into this issue before but I do so little front-end stuff I can't recall how to fix it.

    Here is my function, works just fine in Midori, obviously not in FireFox - and yes, I'm using jQuery but not the jQuery-UI - but this doesn't appear to be a jQuery issue.

    function tiledrop(nnode) {
        "use strict";
        var x, y, tnum, swapnode, swaptile;
        tnum = $(nnode).attr('data-tile');
        x = event.clientX;
        y = event.clientY;
        swapnode = document.elementFromPoint(x, y);
        //make sure it was dropped on another tile
        if ($(swapnode).attr('data-tile')) {
            swaptile = $(swapnode).attr('data-tile');
            swaptiles(tnum, swaptile);
        } else {
    Here is how it is attached to the objects -

    $('#puzzle').find('img').bind('dragend',   function () {tiledrop(this); });
    Basically what it does, when a puzzle piece (square) is dragged onto another, it switches places with it via/ my swapTiles function (which does work everywhere)
    So I have to pass the node of the image being dragged to the function, which gets the node of the image image it was dragged to from the mouse position.

    Works in Midori just dandy, but FireFox event is not global.

    Do I really need to write two different functions and detect which one to attach or is there an elegant way to do it with a single function?

    Any suggests are appreciated.

  2. #2
    Join Date
    Oct 2012
    Found a simpler way to do it without needing to know squat about mouse position. That's better anyway because it seems there is a lot of differences in how browsers report mouse positions.


    Oh - the cross-browser solution w/ jQuery seems to be

    $('#whatever').bind('eventName', function ( event ) {somefunction( event ); });
    jQuery then passes a normalized version of the event object and it should work regardless of browser.
    Last edited by AliceWonder; 01-13-2014 at 10:39 PM. Reason: typo

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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