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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

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:


The Network for Technology Professionals

Search:

About Internet.com

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

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger