--- title: dragenter slug: Web/API/Document/dragenter_event tags: - DOM - Event - drag and drop - 事件 - 参考 - 拖拽 translation_of: Web/API/Document/dragenter_event ---
当拖动的元素或被选择的文本进入有效的放置目标时, dragenter 事件被触发。

基本信息

是否冒泡
是否可取消
目标对象 用户指定的元素或者body元素
接口 {{domxref("DragEvent")}}
默认动作 取消拖动

属性

属性 类型 描述
target {{readonlyInline}} EventTarget 被拖动的元素下面的元素。
type {{readonlyInline}} DOMString 事件类型
bubbles {{readonlyInline}} Boolean 事件是否正常冒泡
cancelable {{readonlyInline}} Boolean 事件是否已被取消?
view {{readonlyInline}} WindowProxy document.defaultView (window of the document)
detail {{readonlyInline}} long (float) 0.
dataTransfer DataTransfer The data that underlies a drag-and-drop operation, known as the drag data store. Protected mode.
currentTarget {{readonlyInline}} EventTarget 触发事件的元素
relatedTarget {{readonlyInline}} EventTarget For mouseover, mouseout, mouseenter and mouseleave events: the target of the complementary event (the mouseleave target in the case of a mouseenter event). null otherwise.
screenX {{readonlyInline}} long 全局(屏幕)坐标中鼠标指针的X坐标。
screenY {{readonlyInline}} long 全局(屏幕)坐标中鼠标指针的Y坐标。
clientX {{readonlyInline}} long 本地(DOM内容)坐标中鼠标指针的X坐标。
clientY {{readonlyInline}} long 本地(DOM内容)坐标中鼠标指针的Y坐标。
button {{readonlyInline}} unsigned short 鼠标事件触发时按下的按钮号:左键= 0,中键= 1(如果存在),右键= 2。 对于配置为左手使用的鼠标,其中按钮操作反转,则值从右向左读取。
buttons {{readonlyInline}} unsigned short The buttons being pressed when the mouse event was fired: Left button=1, Right button=2, Middle (wheel) button=4, 4th button (typically, "Browser Back" button)=8, 5th button (typically, "Browser Forward" button)=16. If two or more buttons are pressed, returns the logical sum of the values. E.g., if Left button and Right button are pressed, returns 3 (=1 | 2). More info.
mozPressure {{readonlyInline}} float 触发事件时屏幕的压力值, 介于0.0到1.0之间
ctrlKey {{readonlyInline}} boolean 事件触发时ctrl键是否被按下
shiftKey {{readonlyInline}} boolean 事件触发时shift键是否被按下
altKey {{readonlyInline}} boolean 事件触发时alt键是否被按下
metaKey {{readonlyInline}} boolean 事件触发时meta键是否被按下

示例:dropzone

{{page('/zh-CN/docs/Web/Events/dragstart', '示例:dropzone')}}

规范

Specification Status Comment
{{SpecName("HTML WHATWG", "interaction.html#dndevents", "dragenter")}} {{Spec2("HTML WHATWG")}}  
{{SpecName("HTML5.1", "editing.html#dndevents", "dragenter")}} {{Spec2("HTML5.1")}} Initial definition

浏览器支持

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 4 {{CompatGeckoDesktop("1.9.1")}} 10 12 3.1
Feature Android Android Webview Chrome for Android Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatIE("10")}} {{CompatNo}} {{CompatNo}}

相关