javascript - How to open an URL in a new tab not in a new window -


this question has answer here:

there many answers on how open url in new window using window.open() opens popup window , that's not need.
problem is: many users have browsers set block popup windows. on other hand, many websites can open new tabs inside thw current window avoiding popup blocker kick in.

window.open('page.htm','_blank')   

triggers popup blocker,

window.location.href='page.htm','_blank'   

opens url in same tab, if '_blank' omitted.

so here's question:
there way tell javascript behave if target='_blank' attribute included in ordinary link?
in other words:
how possible open new tab, preferably using document.location.href?
emphasize don't want open new window because activates popup blocker.
need new tab inside current window.
again, answers proposing window.open() useless me, please don't recommend opens new window.

this may help.

<div onclick="opennewtab('http://www.stackoverflow.com');">click here open new tab</div>  function opennewtab(url) {   var newwindow = window.open(url, '_blank');   newwindow .focus(); } 

working fiddle


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -