HTML - 如何在后台打开一个链接? [英] HTML - how to open a link in the background?

查看:883
本文介绍了HTML - 如何在后台打开一个链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在浏览一些网站,我可以用鼠标右键点击链接(例如在Chrome),然后选择打开新标签 - >选项卡中打开,但会在后台(当前选项卡保留为主选项卡)。

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?

编辑:我试图

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...

推荐答案

您必须删除链接的目标属性:

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.

这篇关于HTML - 如何在后台打开一个链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆