CMXtraneous: Dreamweaver Drag Layer behavior broken in Mozilla with valid doctype (solution provided)

Right on the edge of useful

Dreamweaver Drag Layer behavior broken in Mozilla with valid doctype (solution provided)

Posted Tuesday, November 09, 2004 3:30:25 PM by Danilo Celic

Danilo Celic

Due to "old" coding, the Drag Layer behavior with Dreamweaver (up to and including DWMX2004) does not work in Mozilla, and likely other standards compliant browsers, when the page has a valid doctype, but works in IE6 and probably earlier. There are two methods to fix this problem:

  • Put the browser into quirks mode by deleting, or "breaking" the doctype
  • Fix the broken code

What with everyone clamoring to be valid these days, I'll address the second method, fixing the code. Open up:
{dw install folder}/Configuration/Behaviors/Actions/Drag Layer.js
on my Windows XP Pro system, this is at:
C:/Program Files/Macromedia/Dreamweaver MX 2004/Configuration/Behaviors/Actions/Drag Layer.js

Note: See Dreamweaver Configuration files locations for a location near you.

In Drag layer.js go to line 161 and change it from:
else if (NS6){style.left = newLeft; style.top = newTop;}
to:
else if (NS6){style.left = newLeft+'px'; style.top = newTop+'px';}

Then go down to line 174 and change it from:
else if (NS6) {style.left = MM_targL; style.top = MM_targT;}
to:
else if (NS6) {style.left = MM_targL+'px'; style.top = MM_targT+'px';}

The first change allows the specified layer to be dragged, and the second change allows the layer to snap to a location when dropped if that option is selected within the Drag Layer behavior dialog. Notice in both cases, all we added the units to the values being assigned.

Close and restart Dreamweaver and it should happily add in the correct code to run in valid pages for Mozilla.

Please note that Safari doens't seem to like Drag Layer. It has something to do with Safari being identified as a Netscape browser by the script, and routing of the drag event. Anyway, Safari won't let you drag a layer using this behavior.

Category tags: Dreamweaver, Extensibility, JavaScript