July 23, 2000 - The ondragstart() Method | WebReference

July 23, 2000 - The ondragstart() Method

Yehuda Shiran July 23, 2000
The ondragstart() Method
Tips: July 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

In some applications, you want to take a certain action when the user starts dragging a selected object or an image on the screen. For example, if you have the planets revolving around the Sun, and the sun moves, you may want to stop the planets in their track and continue later, after the last feature is in.

In JavaScript, you use the ondragstart event. You may want to include it in the HTML statement:

<TAG ondragstart = "handler...">
or in a JavaScript statement:

object.dragstart = handler;
The draggable objects are text selections and selected objects. Any text on the page is draggable once it selected is. It may be a fixed text that is part of the page, an entry field, or text area. The following text and image are programmed to give you an alert box. Select any text on this page and then drag it. The alert box will pop up. Now try dragging the photo on the left top corner of the page. The alert box will pop up again. All you need to do is to add to the BODY tag the ondragstart event handler:

<BODY ondragstart="alert('object dragged')>