aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/window/confirm
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/window/confirm
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/window/confirm')
-rw-r--r--files/zh-cn/web/api/window/confirm/index.html70
1 files changed, 70 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/window/confirm/index.html b/files/zh-cn/web/api/window/confirm/index.html
new file mode 100644
index 0000000000..5f021b77e9
--- /dev/null
+++ b/files/zh-cn/web/api/window/confirm/index.html
@@ -0,0 +1,70 @@
+---
+title: Window.confirm()
+slug: Web/API/Window/confirm
+tags:
+ - API
+ - DOM
+ - React-Router
+ - Window
+ - Window.confirm()
+translation_of: Web/API/Window/confirm
+---
+<div>{{ApiRef("Window")}}</div>
+
+<p><code><strong>Window.confirm()</strong></code> 方法显示一个具有一个可选消息和两个按钮(确定和取消)的模态对话框 。</p>
+
+<h2 id="Syntax" name="Syntax">语法</h2>
+
+<pre><em>result</em> = window.confirm(<em>message</em>);
+</pre>
+
+<ul>
+ <li>message 是要在对话框中显示的可选字符串。</li>
+ <li>result 是一个布尔值,表示是选择确定还是取消 (true表示OK)。</li>
+</ul>
+
+<h2 id="Example" name="Example">示例</h2>
+
+<pre>if (window.confirm("Do you really want to leave?")) {
+ window.open("exit.html", "Thanks for Visiting!");
+}
+</pre>
+
+<p>运行结果: </p>
+
+<p><img alt="firefox confirm" src="https://mdn.mozillademos.org/files/7163/firefoxcomfirmdialog_zpsf00ec381.png" style="height: 119px; width: 354px;"><br>
+  </p>
+
+<h2 id="Notes" name="Notes">注意事项:</h2>
+
+<p><span class="comment">The following text is shared between this article, DOM:window.prompt and DOM:window.alert</span>对话框是弹出式(modal)的(也即alert样式, 译者注). 直到这个对话框被点击后, 后面的脚本才会运行. 请勿滥用此功能, 这里列出了很多个理由: <a href="http://alistapart.com/article/neveruseawarning">请放弃使用对话框来确认信息</a>.</p>
+
+<p><a href="/en-US/Chrome" title="Chrome">Mozilla Chrome</a> 的用户(比如Firefox插件开发者)应该使用{{interface("nsIPromptService")}}这个方法.</p>
+
+<p>Chrome浏览器版本 {{CompatChrome(46.0)}} 开始屏蔽内部{{htmlelement("iframe")}}元素, 除非用户在沙箱内开启了<code>allow-modal选项.</code></p>
+
+<p>在{{gecko_minversion_inline("23.0")}}内核中, 参数是可选的.</p>
+
+<h2 id="Specification" name="Specification">兼容性</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML5 Web application', '#dom-confirm', 'confirm()')}}</td>
+ <td>{{Spec2('HTML5 Web application')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="See_also" name="See_also">更多</h2>
+
+<ul>
+ <li>{{domxref("window.alert","alert")}}</li>
+ <li>{{domxref("window.prompt","prompt")}}</li>
+</ul>