Javascript Reference
Categories: onmove

javascript onmove Description

@March 15, 2008, 1:22 a.m.
onmove, onmoveend, onmovestartFirefox/Netscape/NN n/a IE 5.5(Win) Chrome/Safari/DOM n/a  

Bubbles: Yes; Cancelable: No  

When in edit mode, a positionable element set up for dragging receives these events in the following sequence: onmovestart (upon starting the drag), onmove (repeatedly during the drag), and onmoveend (upon release of the mouse button). The following example uses several events to demonstrate IE edit mode scripting (note that the native element dragging mechanism doesn't work well in IE 6 if the <!DOCTYPE> element points to a standards-compatible mode DTD):

<title>IE 5.5 (Windows) Edit Mode</title> 
<style type="text/css">
   body {font-family:Arial, sans-serif}
   #myDIV  {position:absolute; height:100px; width:300px;}
   .regular {border:5px black solid; padding:5px; background-color:lightgreen}
   .moving {border:5px maroon dashed; padding:5px; background-color:lightyellow}
   .chosen {border:5px maroon solid; padding:5px; background-color:lightyellow}
<script type="text/javascript">
// built-in dragging support
// preserve content between modes
var oldHTML = "";

// engage static edit environment
function editOn( ) {
    var elem = event.srcElement;
    elem.className = "chosen";

// engage special edit-move environment
function moveOn( ) {
    var elem = event.srcElement;
    oldHTML = elem.innerHTML;
    elem.className = "moving";

// display coordinates during drag
function trackMove( ) {
    var elem = event.srcElement;
    elem.innerHTML = "Element is now at: " + elem.offsetLeft + ", " +

// turn off special edit-move environment
function moveOff( ) {
    var elem = event.srcElement;
    elem.innerHTML = oldHTML;
    elem.className = "chosen";

// restore original environment (wrapper gets onfocusout)
function editOff( ) {
    var elem = event.srcElement;
    if ( == "wrapper") {
        elem.firstChild.className = "regular";

// initialize event handlers
function init( ) {
    document.body.oncontrolselect = editOn;
    document.body.onmovestart = moveOn;
    document.body.onmove = trackMove;
    document.body.onmoveend = moveOff;
    document.body.onfocusout = editOff;
<body onload="init( );">
<div id="wrapper" contenteditable="true">
    <div id="myDIV" class="regular">
        This is a positioned element with some text in it.
Typical Targets

An XML LayoutRect object.

I use Firefox every day. Firebug is great for developers.
javascript manual - 2010-04-06
I agree. But in this example, onmove event works on IE only.
javascript manual - 2010-04-06
How can you not use standards? IE is the worst browser out there. You should start coding for this century and stop using IE specific functions.
A Web Guy - 2010-04-06

Powered by Linode.