asp.net.ph

ondragstart Event

DHTML Events


Fires on the source object when the user first starts to drag a text selection or selected object.

Syntax


Inline HTML <element ondragstart = "handler" ... > All platforms
Event property object.ondragstart = handler ECMA-262 Language Specification
Named script <script FOR=object EVENT=ondragstart> Internet Explorer® only

Remarks


Bubbles Yes
Cancels Yes
To invoke Drag the selected text or object.
Default action Calls the associated event handler.

The ondragstart event is the first to fire when a drag procedure is initiated. It is essential to every drag operation, yet is just one of several source events in the data-transfer object model. Source events use the setData method of the dataTransfer object to provide information about data being transferred. The list of source events includes:

Event Object Properties

While event handlers in the Document Object Model do not receive parameters directly, the handler can query the event object for data.

Event Object Properties


Example

This example detects the tagName of the object from which the ondragstart event has originated. Because the event bubbles, it can be handled at the BODY level.

<body ondragstart="
  alert('You have dragged something from the '+ 
  event.srcElement.tagName)">
<div align="center">
<h5>Select and drag any text on this document.</h5>
<input type=text value="This is a textbox" readOnly>
<br><br>
<span>This is a span</span>
<br><br>
<textarea readOnly>This is a textarea</textarea>
</div>
</body>

 Show me 


This example shows the order of event firing for drag-and-drop events.

<head>
<script language="JavaScript">
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;
theResults.add(oNewOption,0);}
</script>
<head>

<body>
<div align="center">
<p>Source events are wired up to this text box.</p>
<input id=theSource value="Text to Drag"
  ondragstart="ShowResults()"
  ondrag="ShowResults()"
  ondragend="ShowResults()">
<br>
<p>Target events are bound to this text box.</p>
<input id=theTarget value="Drag Destination"
  ondragenter="ShowResults()"
  ondragover="ShowResults()"
  ondragleave="ShowResults()"
  ondrop="ShowResults()">
<br>
<select id="theResults" size=15>
  <option>List of events fired, 
    starting with the most recent</select>
</div>
</body>

This feature requires Microsoft® Internet Explorer® 5.0 or later.

 Show me 

See Also

Data Transfer Overview, onbeforecut, onbeforecopy, oncut, oncopy, ondrag, ondragend




Contents
HTML Elements
HTML Element Attributes
CSS Attributes
DOM Objects
DOM Object Properties
DOM Events Reference
DOM Methods Reference
DOM Collections Reference
 

Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph