问题
I am browsing some websites, I can click (for example in Chrome) on the link with the right button and choose OPEN IN THE NEW TAB -> the tab is opened, but in the background (the current tab stays as the main tab).
I am trying to do with the link - I added to the link the attribute target="_blank", but always as the main tab is displayed the new one - not the tab from which I opened the new tab.
Is there any way, how to do that?
EDIT: What I am trying:
javascript.js
$(document).ready(function(){
$('a[target="_blank"]').removeAttr('target');
...
})
<a href="http://www.google.com" id="id_attribute">link</a>
But the page is always opened in the same window...
回答1:
You must remove the link's target attribute:
$('a[target="_blank"]').removeAttr('target');
Then it will stay in the same window without changing to the new one that opens by clicking the link.
来源:https://stackoverflow.com/questions/12814261/html-how-to-open-a-link-in-the-background