如何在新窗口中打开链接(以及同一新窗口中的所有后续链接)?

时间:2016-09-03 03:42:19

标签: jquery html angularjs

我有一个AngularJS应用程序,我成功地将控制器分离为打开窗口的超链接,并且超链接的目标已成功设置为新窗口。

我的问题是,我如何只分配一个窗口来打开所有新链接,从而阻止其他新窗口打开。

我怀疑的是我需要以某种方式使用window.location.href修改url位置..

我怎样才能做到这一点?

2 个答案:

答案 0 :(得分:3)

您可以将目标设置为_blank_self_parent_top以外的任何关键字。然后对要用于此窗口的任何其他链接使用相同的名称,然后进行设置。

参考:http://www.w3schools.com/tags/att_link_target.asp

答案 1 :(得分:1)

你不能

每次使用新标签时,都会使用target元素的a属性打开。

来自w3schools

|   Value   |  Description                                            |
---------------------------------------------------------------------
| _blank    | Opens the linked document in a new window or tab        |
| _self     | Opens the linked document in the same frame (default)   |
| _parent   | Opens the linked document in the parent frame           |
| _top      | Opens the linked document in the full body of the window|
| framename |   Opens the linked document in a named frame            |

示例: https://jsfiddle.net/e5arnb61/

<a href="https://www.google.co.il/#q=search1" target="_blank">This alway open new tab</a>
<br><br>
<a href="https://www.google.co.il/#q=search2" target="_blank">This alway open new tab</a>
相关问题