diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
| commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
| tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/history/scrollrestoration/index.html | |
| parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
| download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip | |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/history/scrollrestoration/index.html')
| -rw-r--r-- | files/zh-cn/web/api/history/scrollrestoration/index.html | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/history/scrollrestoration/index.html b/files/zh-cn/web/api/history/scrollrestoration/index.html new file mode 100644 index 0000000000..9ae0fa7d9b --- /dev/null +++ b/files/zh-cn/web/api/history/scrollrestoration/index.html @@ -0,0 +1,75 @@ +--- +title: History.scrollRestoration +slug: Web/API/History/scrollRestoration +tags: + - API + - HTML DOM + - History + - History API + - Property + - Reference +translation_of: Web/API/History/scrollRestoration +--- +<div>{{APIRef("History API")}}</div> + +<div></div> + +<p>{DOMxRef("History"))的接口——<strong><code>滚动恢复属性</code></strong>允许web应用程序在历史导航上显式地设置默认滚动恢复行为</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">const <em>scrollRestore</em> = history.scrollRestoration</pre> + +<h3 id="值">值</h3> + +<dl> + <dt><code>auto</code></dt> + <dd>将恢复用户已滚动到的页面上的位置。</dd> + <dt><code>manual</code></dt> + <dd>未还原页上的位置。用户必须手动滚动到该位置。</dd> +</dl> + +<h2 id="案例">案例</h2> + +<h3 id="查看当前页面滚动恢复行为">查看当前页面滚动恢复行为</h3> + +<pre class="brush: js">const scrollRestoration = history.scrollRestoration +if (scrollRestoration === 'manual') { + console.log('The location on the page is not restored, user will need to scroll manually.'); +} +</pre> + +<h3 id="防止自动恢复页面位置">防止自动恢复页面位置</h3> + +<pre class="brush: js">if (history.scrollRestoration) { + history.scrollRestoration = 'manual'; +} +</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">评论</th> + </tr> + <tr> + <td>{{SpecName("HTML WHATWG", "#scroll-restoration-mode", "scroll restoration mode")}}</td> + <td>{{Spec2("HTML WHATWG")}}</td> + <td>No change from {{SpecName("HTML5 W3C")}}.</td> + </tr> + <tr> + <td>{{SpecName("HTML5 W3C", "browsers.html#dom-history-scrollrestoration", "History.scrollRestoration")}}</td> + <td>{{Spec2("HTML5 W3C")}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<div class="hidden">从结构化数据生成。如果您想对数据进行贡献,请查看https://github.com/mdn/browser-compat-data并向我们发送pull request这个t上的兼容性表能力这一页是</div> + +<p>{{Compat("api.History.scrollRestoration")}}</p> |
