HTML 元素的 ondragenter 事件

ondragenter Event

DHTML文档教程

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

dhtml语法

Inline HTML

<ELEMENT ondragenter = "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 = object EVENT = 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 an event object for data.

Remarks

You can handle the ondragenter event 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 the getData method 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 the returnvalue property 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"

ondragstart="ShowResults()"

ondrag="ShowResults()"

ondragend="ShowResults()"

>  

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

<INPUT ID=txtDragDestination VALUE="Drag Destination"

ondragenter="ShowResults()"

ondragover="ShowResults()"

ondragleave="ShowResults()"

ondrop="ShowResults()"

>  

<SELECT ID=oResults SIZE=30>

<OPTION>List of Events Fired

</SELECT>

</BODY>

 

你可能感兴趣的:(html,object,VBScript,events,scripting,firing)