From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/event/istrusted/index.html | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 files/zh-cn/web/api/event/istrusted/index.html (limited to 'files/zh-cn/web/api/event/istrusted') diff --git a/files/zh-cn/web/api/event/istrusted/index.html b/files/zh-cn/web/api/event/istrusted/index.html new file mode 100644 index 0000000000..275d384acd --- /dev/null +++ b/files/zh-cn/web/api/event/istrusted/index.html @@ -0,0 +1,62 @@ +--- +title: Event.isTrusted +slug: Web/API/Event/isTrusted +tags: + - API + - Event + - Reference + - 只读 + - 属性 +translation_of: Web/API/Event/isTrusted +--- +
{{APIRef("DOM")}}
+ +

{{domxref("Event")}} 接口的 isTrusted 属性是一个只读属性,它是一个布尔值({{domxref("Boolean")}})。当事件是由用户行为生成的时候,这个属性的值为 true ,而当事件是由脚本创建、修改、通过 {{domxref("EventTarget.dispatchEvent()")}} 派发的时候,这个属性的值为 false 。

+ +

语法

+ +
var eventIsTrusted = event.isTrusted;
+
+ +

+ +

{{domxref("Boolean")}} (布尔值)

+ +

示例

+ +
if (e.isTrusted) {
+  /* Event 事件可信 */
+} else {
+  /* Event 事件不可信 */
+}
+
+ +

规范

+ + + + + + + + + + + + + + + + + + + +
规范现状意见
{{SpecName('DOM WHATWG', '#dom-event-istrusted', 'Event.isTrusted')}}{{ Spec2('DOM WHATWG') }}
{{SpecName('DOM3 Events', '#trusted-events', 'Trusted events')}}{{Spec2('DOM3 Events')}}添加有关受信任与不受信任事件的请求,而 isTrusted 属性并非由其定义。
+ +

浏览器支持

+ +
+ + +

{{Compat("api.Event.isTrusted")}}

+
-- cgit v1.2.3-54-g00ecf