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

时间:2023-01-21 23:48:30

I have an AngularJS app which I successfully got to segregate controllers for the hyperlinks to open windows and the target of the hyperlinks was successfully set as a new window.

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

My problem is, how do I only allocate one and only one window to open all new links, thereby preventing additional new windows from opening.

我的问题是,如何只分配一个窗口和一个窗口来打开所有的新链接,从而防止额外的新窗口打开。

What I am suspecting is that I need window.location.href used in some way to modify the url location..

我怀疑的是我需要窗户。href在某种程度上用于修改url位置。

How can I achieve this?

我怎样才能做到这一点呢?

3 个解决方案

#1


3  

You set the target to any keywords other than _blank, _self, _parent, or _top. Then use that same name for any other links you want to target to this window and you're set.

您将目标设置为除了_blank、_self、_parent或_top之外的任何关键字。然后使用相同的名称为您想要指向这个窗口的任何其他链接,然后设置。

Reference: http://www.w3schools.com/tags/att_link_target.asp

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

#2


1  

You cannot

Use target attribute of the a element to open each time a new tab.

使用一个元素的目标属性在每次新选项卡中打开。

From w3schools:

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

Example: https://jsfiddle.net/e5arnb61/

例如: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>

#3


-1  

The keyword to use is target="_new" on each link to open in the same new window.

在同一个新窗口中,每个链接上使用的关键字是target="_new"。

#1


3  

You set the target to any keywords other than _blank, _self, _parent, or _top. Then use that same name for any other links you want to target to this window and you're set.

您将目标设置为除了_blank、_self、_parent或_top之外的任何关键字。然后使用相同的名称为您想要指向这个窗口的任何其他链接,然后设置。

Reference: http://www.w3schools.com/tags/att_link_target.asp

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

#2


1  

You cannot

Use target attribute of the a element to open each time a new tab.

使用一个元素的目标属性在每次新选项卡中打开。

From w3schools:

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

Example: https://jsfiddle.net/e5arnb61/

例如: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>

#3


-1  

The keyword to use is target="_new" on each link to open in the same new window.

在同一个新窗口中,每个链接上使用的关键字是target="_new"。