window.open is opening new window instead of new tab
Though in all modern browsers window.open opens a new tab instead of a new window but in some cases it can still open new window. Like in my case on a particular test machine due to browser plug-in(ad-blocker or similar) installed and it was forcing to open in new window. And we were told to resolve this issue programmatically, because it was working well in case of Gmail.
I did some research and found that Gmail button click was not calling window.open it was actually an a tag click with target “_blank” so ad blocker was not doing any interruption in that and a new tab was being opened. In our case we were clicking an HTML button.
I did some research for the solution but did not get succeeded. Then I tried to post it on “Stackoverflow.com” it was already overflowed by similar queries.
Below are few links from there:
but none of them was working in my scenario. In one the above question’s comment some posted that we should create an A tag runtime with target blank and then fire its click event so it should work. But due to some browser security or so it was not working on any machine.
“Every failed attempt/step takes you closer to the success”
What we need to do is on button’s click we need to create a form having target “_blank” and action value as the URL and method =”get” and then submit that.
It worked like a charm.
You can find complete solution in a fiddle here http://goo.gl/yd0yJK .