# target属性注入

## 概述

[target](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) 属性指定在何处显示链接的URL作为浏览上下文（标签、窗口或 `<iframe>`）的名称。以下关键字对于加载URL的位置有特殊含义：

* `_self` - 当前的浏览上下文，默认值。
* `_blank` - 通常是一个新标签页，但用户可以配置浏览器改为打开新窗口。
* `_parent` - 当前浏览上下文的父级，如果没有父级，行为如同 `_self`。
* `_top` - 最顶层的浏览上下文（当前上下文的"最高"祖先），如果没有祖先，行为如同 `_self`。

## \_blank

使用 `target=_blank` 允许链接页面通过 [window.opener](https://developer.mozilla.org/en-US/docs/Web/API/Window/opener) API 获取对源页面的部分访问权限。新打开的标签页然后可以将 `window.opener.location` 更改为钓鱼页面或在打开者页面上执行JavaScript。

{% hint style="info" %}
在较新的浏览器版本（例如Firefox 79+）中，在 `<a>` 元素上设置target="\_blank"会隐式提供与设置 `rel="noopener"` 相同的 `rel` 行为。
{% endhint %}

## 参考资料

* [Target="\_blank" — 最被低估的漏洞](https://medium.com/@jitbit/target-blank-the-most-underestimated-vulnerability-ever-96e328301f4c)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.cdxiaodong.life/web-ying-yong-an-quan/html-zhu-ru/target.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
