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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint