Actually my real scenario is
When user opens the modal pop up (say bootstrap modal pop up http://getbootstrap.com/javascript/#modals), we need to open a url which is already saved by the user.
So for that I have tried to open with window.open. But this is always blocking me. Is there any way to overcome this?
The following scenarios I have tried.
When I try to open using window.open(link, '_blank');
and if browser has the blocked the pop up, then I restricted by browser to open the url in new tab.
To over come this I have tried like (following) creating anchor link and triggering click event. But this is also not also working.
var link = document.createElement('a');
link.setAttribute('href', url);
link.target="_blank";
var event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(event);
Some websites by passing this feature.
For example, https://www.online.citibank.co.in/.
When I click log in button, a new window is opening. They also doing the same functionality as window.open. But the browser is not blocking citibank new window.
I don't know what is the reason behind this. How to implement this feature?