[thelist] Netscape/Mozilla js problem

Greg Weiler wilee at golden.net
Mon Mar 24 21:51:27 CST 2003


I use the following code to as part of a page that allows divs to be dragged
around. The page works in IE6, but not in NN7/Mozilla. I get an error at:
"topCoord = parseInt(e.target.style.top);" which says that e.target.style
has no properties. I'm stuck as to what to do next?
Any help greatly appreciated.

Code:

//function to get mouse position while dragging
function dragIt(e){
        duringdrag = true;
        if (!e) var e = window.event;
//check for IE or Netscape mouse position
        if (e.pageX || e.pageY){
  posx = e.pageX;
 } else if (e.clientX || e.clientY){
  posx = e.clientX + document.body.scrollLeft;
  posy = e.clientY + document.body.scrollTop;
 }
//check for IE or Netscape event target
 if (e.target){
 topCoord = parseInt(e.target.style.top);
 leftCoord = parseInt(e.target.style.left);
 e.target.onmousemove = moveDiv;
 } else if (e.srcElement){
 topCoord = parseInt(e.srcElement.style.top);
 leftCoord = parseInt(e.srcElement.style.left);
 e.srcElement.onmousemove = moveDiv;
 }
}
:::::::::::::::::::::::::::::::::::::
Greg Weiler
www.gregweiler.ca
:::::::::::::::::::::::::::::::::::::




More information about the thelist mailing list