Although this question is similar to my question, but my requirement is we have to only use HTML.
<a href="https://stackoverflow.com/" target="_blank">Stack Overflow</a>
If we use above code then it opens Stack Overflow website in new tab but focus will move to Stack Overflow website. My requirement is focus should still remain in current tab and it should open Stack Overflow website.
Basically I want Open link in new tab or Ctrl Left_click feature in HTML.
CodePudding user response:
HTML provides no mechanism for the website developer to control this.
CodePudding user response:
Unfortunately I Don't think there's an API to do this. But the browsers have a defualt behaviour that you if you click on any link along with control button pressed it will open the new tab and focus will remain of existing tab.
As a workaround, you can try simulating Ctrl Click using JS on an anchor tag created.
https://stackoverflow.com/a/11389138/13218645
CodePudding user response:
In HTML there is no standard way to stay in same page target="_blank" . If you want to stay in same page toy need to use some scripting code.
<a href="www.stackoverflow.com" onclick="window.open('#','_blank');window.open(this.href,'_self');">
This will load the current web page in a new tab which the browser will focus on, and then load the href in the current tab