HTML 元素的 ondragenter 事件

ondragenter Event

DHTML文档教程

Fires on the target element when the user drags theobjectto a valid drop target.

dhtml语法

Inline HTML

<ELEMENTondragenter= "handler" ... >

All platforms

Event property

object.ondragenter=handler

JScript only

object.ondragenter= GetRef("handler")

Visual Basic Scripting Edition (VBScript) 5.0 or later only

Named script

<SCRIPT FOR=objectEVENT=ondragenter>

Internet Explorer only

Event Information

Bubbles

Yes

Cancels

Yes

To invoke

· Drag the selection over a valid drop target within the browser.

· Drag the selection to a valid drop target within another browser window.

Default action

Calls the associated event handler.

Event Object Properties

Although event handlers in the DHTML Object Model do not receive parameters directly, a handler can query aneventobject for data.

Remarks

You can handle theondragenterevent on the source or on the target object. Of the target events, it is the first to fire during a drag operation. Target events use thegetDatamethod to stipulate which data and data formats to retrieve. The list of drag-and-drop target events includes:

· onbeforepaste

· onpaste

· ondragenter

· ondragover

· ondragleave

· ondrop

when scripting custom functionality, use thereturnvalueproperty to disable the default action.

DHTML代码范例

This example shows when and where each event fires during a drag-and-drop operation by listing each event and the name of the object firing it in a list box.

<HEAD>

<SCRIPT>

var oNewOption;

// Code for dynamically adding options to a select.

function ShowResults()

{ // Information about the events

// and what object fired them.

arg = event.type + " fired by " + event.srcElement.id;

oNewOption = new Option();

oNewOption.text = arg;

oResults.add(oNewOption,0);

}

</SCRIPT>

</HEAD>

<BODY>

<P>Source events are wired up to this text box.</P>

<INPUT ID=txtDragOrigin VALUE="Text to Drag"

οndragstart="ShowResults()"

οndrag="ShowResults()"

οndragend="ShowResults()"

>

<P>Target events are bound to this text box.</P>

<INPUT ID=txtDragDestination VALUE="Drag Destination"

οndragenter="ShowResults()"

οndragοver="ShowResults()"

οndragleave="ShowResults()"

οndrοp="ShowResults()"

>

<SELECT ID=oResults SIZE=30>

<OPTION>List of Events Fired

</SELECT>

</BODY>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值