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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

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')>

People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business