Question

I simulate a mouse click hyperlink pop-up window is blocked , but when you click on the link with the mouse manually windows are displayed in the Tab , not pop , how to make analog click the link to open a link in a tab instead of pop-ups ?

runtime envrionment is chrome.

var div = $(this).find('div.item_cont.bor2.bg2');
            var a = $('a', div);
            if (a.length < 1) return;
            var ev = document.createEvent('MouseEvent');
            ev.initMouseEvent("click", true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, false, a);
            a.get(0).dispatchEvent(ev);

the html is like:

<a target="_blank" class="mr5" href="http://www.example.com/xxx/xxx">click me</a>
Was it helpful?

Solution

This is intended. window.open and other link clicks will only open a tab if they are generated from the user. Many spam sites will try and do something like what you have done here to attempt to by-pass the popup blocker.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top