Event not bubbling in some Browsers when clicked on Flash

后端 未结 4 798
天命终不由人
天命终不由人 2020-12-11 17:48

Environment: Windows 7, Internet Explorer 8, Flash ActiveX 10.1.53.64, wmode=transparent

Just wrote a small test page that you can load in IE and Firefox or any othe

4条回答
  •  误落风尘
    2020-12-11 18:30

    We wrestled with this problem quite a bit and finally came to simple solution.

    When a click happens over an embed you can hide the embed, then re trigger the click event. For chrome this code relies on a wrapper element for the flash movie that captures the click, give this wrapper element the class "enableclickthrough" -- here is some jquery code that accomplishes this:

    Edit: updated this for my own needs so the code is more selective about what flash movies can be clicked through -- now its only ones that have a class of enableclickthrough or are the child of an element with that class

    // When a mouse up occurs on an embed or a holder element taged with class enableclickthrough, then hide the element and refire the click
    $(document).ready(function (){
        $('body').mouseup(function (event) {
            var offset = $(this).offset(),
                clientX = event.clientX,
                clientY = event.clientY,
                left = offset.left,
                top = offset.top,
                x = clientX - left,
                y = clientY - top,
                target = $(event.target),
                display = $(target).css('display'),
                passClickTo;
    
            if (typeof clientX != 'undefined' && (target.parent().hasClass('enableclickthrough') || target.hasClass('enableclickthrough'))) {
                target.css('display', 'none');
                // If you don't pull it out of the array for some reason it doesn't work in all instances
                passClickTo = $(document.elementFromPoint(x, y));
                passClickTo[0].click(); 
                target.css('display', display);
                return false;
            }
        });
    });
    

    Here is an example of a flash movie with a wrapper element to allow this to function properly in chrome

    Keep in mind this solution is for flash movies that do not have interactive components in them.

    I hope this helps other that have this issue with flash movies.

    Best regards

    Will Ferrer

提交回复
热议问题