Comment 7 for bug 1129281

Revision history for this message
Olivier Tilloy (osomon) wrote :

I have linked a branch that implements the suggested idea (use javascript event delegation to install a handler for the page when it’s loaded and intercept all hyperlink activations). This works very well for normal hyperlinks with target = "_blank".

However, it looks like twitter does additional processing of those links. According to the webkit web inspector, an event listener is installed on the document (from https://platform.twitter.com/widgets.js) which does the following:

    function p(a) {
        a = a || window.event;
        var b = a.target || a.srcElement, c, d, e;
        while (b && b.nodeName.toLowerCase() !== "a") b = b.parentNode;
        b && b.nodeName.toLowerCase() === "a" && b.href && (c = b.href.match(f), c && (e = o(b.href), e = e.replace(/^http[:]/, "https:"), e = e.replace(/^\/\//, "https://"), q(e, b), a.returnValue = !1, a.preventDefault && a.preventDefault()));
    }

So, for some reason that I don’t fully understand yet, this listener cancels the event without stopping further propagation of it (see https://developer.mozilla.org/en-US/docs/DOM/event.preventDefault). I suspect this listener is what prevents my custom handler from getting the click event. Needs more investigation.