Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zh-cn]: update the translation of Location hash property #24798

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions files/zh-cn/web/api/location/hash/index.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
---
title: "Location: hash"
title: Locationhash 属性
slug: Web/API/Location/hash
l10n:
sourceCommit: 6033c369db35bf1df34430cc375705e2d959fc0b
---

{{ APIRef("Location") }}

{{domxref("Location")}} 接口的 **`hash`** 属性返回一个 {{domxref("USVString")}},其中会包含 URL 标识中的 `'#'` 和 后面 URL 片段标识符
{{domxref("Location")}} 接口的 **`hash`** 属性返回一个字符串,其中包含一个 `'#'`,后跟 URL 的片段标识符——URL 试图指向的页面上的 ID

这里 fragment 不会经过[百分比编码](/zh-CN/docs/Glossary/Percent-encoding)(URL 编码)。如果 URL 中没有 fragment,该属性会包含一个空字符串,`""`
该片段标识符没有进行{{Glossary("Percent-encoding", "百分号编码")}}。如果 URL 没有片段标识符,则此属性的值为空字符串 `""`
T34-active marked this conversation as resolved.
Show resolved Hide resolved

## Syntax
##

```plain
string = object.hash;
object.hash = string;
```
字符串。

## 示例

## Examples
假设用户已导航至 `https://example.org#examples`,以下代码将会打印 `#examples`:

```html
<a id="myAnchor" href="/zh-CN/docs/Location.href#Examples">Examples</a>
<script>
var anchor = document.getElementById("myAnchor");
console.log(anchor.hash); // 返回'#Examples'
</script>
```js
const result = location.hash;
console.log(result);
```

## Specifications
## 规范

{{Specifications}}

## Browser compatibility
## 浏览器兼容性

{{Compat}}
Loading