How to open a url in new active tab.by OpenInNewtab without using the event property

68 views
Skip to first unread message

Zhe Lee

unread,
Jan 25, 2017, 3:35:52 AM1/25/17
to greasemonkey-users

How to open a url in new active tab.by OpenInNewtab without using the event property

Why I Replace The Event.Property With

http://www.htmlgoodies.com/beyond/javascript/events-and-javascript-part-3-the-event-object.html

0125162831.png

GM_openInTab(link.href, event.button || event.ctrlKey); // open in active window
GM_openInTab(link.href, 1);                             // open in inactive window 
GM_openInTab(link.href, true);                             // open in inactive window

I even try this but it doesn’t work either.

bl = new Boolean(true);
GM_openInTab(link.href, bl);                             // open in inactive window

All The Code

function OpenInNewtab()
{
    var allLinks = document.querySelectorAll('h3.r a');

    //alert(allLinks.length);
    // Bind the event handler to each link individually
    for (var i = 0, n = allLinks.length; i < n; i++) {
        allLinks[i].addEventListener('mouseup', function (event) {
            var link = allLinks[0];
            // alert(link.href);
            if (link) {
                alert(link.href);
                //GM_openInTab(link.href);
                //alert(event.button);
                GM_openInTab(link.href, event.button || event.ctrlKey); // open in active window
                GM_openInTab(link.href, 1);                             // open in inactive window 
                suppressing = true;
                prevent(e);
            }
        });
    }
}
Reply all
Reply to author
Forward
0 new messages