HTML - how to open a link in the background?

China☆狼群 提交于 2019-12-11 19:13:57

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!