469,275 Members | 1,540 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

firefox compatibility

1
Hey anybody can help me out wid this code..Its working well in IE but nt in firefox.The problem lies in offset,clientX,clientY part but I dnt know how to resolve it ..

Expand|Select|Wrap|Line Numbers
  1. var zxcDockAry=new Array();
  2. var zxcBdy,zxcObj,zxcWDone,zxcWDCnt,zxcXos,zxcYos,zxcTD,zxcDiv;
  3. var zxcDragDo=false;
  4.  
  5. function zxcInit(){
  6.  zxcBdy = document.getElementsByTagName('BODY')[0];
  7.  zxcdocks=zxcBdy.getElementsByTagName('TR');
  8.  for (zxc1=0;zxc1<zxcdocks.length;zxc1++){
  9.   if (zxcdocks[zxc1].className=='TileDock'){
  10.    zxcdocks[zxc1].spell=zxcdocks[zxc1].title;
  11.    zxcdocks[zxc1].removeAttribute('title');
  12.    zxcdocks[zxc1].ary=new Array();
  13.    zxctds=zxcdocks[zxc1].getElementsByTagName('TD');
  14.    for (zxc2=1;zxc2<zxctds.length;zxc2++){
  15.     if (zxctds[zxc2].className=='Dock'){
  16.      zxcDockAry[zxcDockAry.length]=zxctds[zxc2];
  17.     }
  18.     zxctds[zxc2].style.position='relative';
  19.     zxctds[zxc2].spell='';
  20.     zxcdocks[zxc1].ary[zxcdocks[zxc1].ary.length]=zxctds[zxc2];
  21.    }
  22.   }
  23.  }
  24.  
  25. }
  26. function zxcMouseDown(e){
  27.  if (!document.all){ zxcobj=e.target; zxcparent='HTML'; }
  28.  else { zxcobj=event.srcElement; zxcparent='BODY'; }
  29.  if (!zxcobj.className){ return; }
  30.  while (zxcobj.tagName!=zxcparent&&zxcobj.className!='drag'){
  31.   if (!document.all){ zxcobj=zxcobj.parentNode; }
  32.   else { zxcobj=zxcobj.parentElement; }
  33.  }
  34. var divobj = document.getElementById("centercontent");
  35. var divobj_width = parseInt(divobj.style.width);
  36. var divobj_height = parseInt(divobj.style.height);
  37. if (( zxcobj.className=='drag') &&
  38.      ( ( zxcPos(zxcobj)[0] > zxcPos(divobj)[0] &&  (zxcPos(zxcobj)[0] < (zxcPos(divobj)[0] + divobj_width ) ) ) && 
  39.        ( zxcPos(zxcobj)[1] > zxcPos(divobj)[1] &&  (zxcPos(zxcobj)[1] < (zxcPos(divobj)[1] + divobj_height) ) ) ) )
  40. {
  41.   zxcDragDo=true;
  42.   zxcObj=zxcobj;
  43.   zxcObj.style.position='absolute';
  44.   zxcObj.style.left=zxcObj.offsetLeft+'px';
  45.   zxcObj.style.top=zxcObj.offsetTop+'px';
  46.   zxcXos=zxcObj.offsetLeft-zxcMse(e)[0];
  47.   zxcYos=zxcObj.offsetTop-zxcMse(e)[1];
  48.   document.onmousemove=zxcDrag;
  49.   return true;
  50.   } else if (zxcobj.className=='drag')  {
  51.   zxcDragDo=true;
  52.   zxcObj=zxcobj.cloneNode(true);
  53.   zxcBdy.appendChild(zxcObj);
  54.   zxcObj.style.position='absolute';
  55.   zxcObj.style.left=(zxcPos(zxcobj)[0])+'px';
  56.   zxcObj.style.top=(zxcPos(zxcobj)[1])+'px';
  57.   zxcXos=zxcObj.offsetLeft-zxcMse(e)[0];
  58.   zxcYos=zxcObj.offsetTop-zxcMse(e)[1];
  59.   document.onmousemove=zxcDrag;
  60.   return true;
  61.  }
  62. }
  63.  
  64.  
  65.  
  66. function zxcDrag(e){
  67.  if (zxcDragDo){
  68.   zxcObj.style.left=(zxcMse(e)[0]+zxcXos)+'px';
  69.   zxcObj.style.top=(zxcMse(e)[1]+zxcYos)+'px';
  70.  
  71.   return false;
  72.  }
  73. }
  74.  
  75. function zxcMse(e){
  76.   if (!document.all){ return [e.clientX,e.clientY] }
  77.   else { return [event.clientX,event.clientY]; }
  78.  
  79. }
  80.  
  81. function zxcMseUp(){
  82. var divobj = document.getElementById("centercontent");
  83. var divobj_width = parseInt(divobj.style.width);
  84. var divobj_height = parseInt(divobj.style.height);
  85.  
  86.  if ( ( (zxcPos(zxcobj)[0] > zxcPos(divobj)[0]) &&  (zxcPos(zxcobj)[0] < (zxcPos(divobj)[0] + divobj_width ) ) ) && 
  87.       ( (zxcPos(zxcobj)[1] > zxcPos(divobj)[1]) &&  (zxcPos(zxcobj)[1] < (zxcPos(divobj)[1] + divobj_height) ) ) )
  88.     {
  89.     zxcMseUpNotAdd();
  90.     }
  91. else
  92.    { 
  93.     zxcMseUpAdd();
  94.     } 
  95.  
  96.  
  97. }
  98.  
  99.  
  100. function zxcMseUpAdd(){
  101.  zxcDragDo=false;
  102.   var divobj = document.getElementById("centercontent");
  103. var divobj_width = parseInt(divobj.style.width);
  104. var divobj_height = parseInt(divobj.style.height);
  105.  zxcTD=zxcDockCk();
  106.  if (zxcTD){
  107.   id = zxcObj.id;
  108.  add_product(id);
  109. zxcDiv=zxcTD.getElementsByTagName('DIV');
  110.   zxcDiv=zxcTD.getElementsByTagName('DIV')[0];
  111.   zxcimg=zxcDiv.getElementsByTagName('IMG'); 
  112.       if (zxcimg.length){ zxcDiv.removeChild(zxcimg[0]); }
  113.  
  114.     }
  115. else
  116.     {
  117.         //alert('bracelet');
  118.         if (((zxcPos(zxcObj)[0] > zxcPos(divobj)[0]) && (zxcPos(zxcObj)[0] < (zxcPos(divobj)[0] + divobj_width))) && 
  119.                ((zxcPos(zxcObj)[1] > zxcPos(divobj)[1]) && (zxcPos(zxcObj)[1] < (zxcPos(divobj)[1] + divobj_height))))
  120.  
  121.         { alert('braceletout');
  122.         zxcObj.style.left='-1200px'; 
  123.         zxcMseUpRemove();
  124.         }
  125.         else
  126.         { alert('bracelet');
  127.         zxcObj.style.left='-1200px';
  128.         }
  129.  
  130.     }
  131.  
  132. }
  133.  
  134. function zxcMseUpNotAdd(){
  135.  zxcDragDo=false;
  136.  var divobj = document.getElementById("centercontent");
  137. var divobj_width = parseInt(divobj.style.width);
  138. var divobj_height = parseInt(divobj.style.height);
  139. if (((zxcPos(zxcObj)[0] > zxcPos(divobj)[0]) && (zxcPos(zxcObj)[0] < (zxcPos(divobj)[0] + divobj_width))) && 
  140.                ((zxcPos(zxcObj)[1] > zxcPos(divobj)[1]) && (zxcPos(zxcObj)[1] < (zxcPos(divobj)[1] + divobj_height))))
  141.  
  142.          {
  143.                 zxcTD=zxcDockCk();
  144.              if (zxcTD){
  145.                   zxcDiv=zxcTD.getElementsByTagName('DIV');
  146.                    zxcDiv=zxcTD.getElementsByTagName('DIV')[0];
  147.                   zxcimg=zxcDiv.getElementsByTagName('IMG'); 
  148.  
  149.                        }
  150.  
  151.          }
  152.          else
  153.          {
  154.     //     zxcObj.style.left='-1200px'; 
  155.     //     zxcMseUpRemove();
  156.          }
  157. }
  158.  
  159.  
  160. function zxcMseUpRemove(){
  161. zxcDragDo=false;
  162. id = zxcObj.id;
  163. document.onmouseup=doBuyNowGet('ajax_shopping_cart.php?action=remove_product_ajax&products_id='+id);
  164. id.style.left='-1200px';
  165. }
  166.  
  167.  function add_product(id)
  168.  {
  169.    document.onmouseup=doBuyNowGet('ajax_shopping_cart.php?action=buy_now&products_id='+id);
  170.  
  171.    zxcDiv=document.getElementsByTagName('DIV');
  172.    zxcDiv=document.getElementsByTagName('DIV')[0];
  173.    zxcimg=document.getElementsByTagName('IMG'); 
  174.  
  175. //return id;
  176.   }
  177.  
  178. function zxcDockCk(){
  179.  for (zxc0=0;zxc0<zxcDockAry.length;zxc0++){
  180.   if (zxcPos(zxcObj)[0]>zxcPos(zxcDockAry[zxc0])[0]&&
  181.         zxcPos(zxcObj)[0] + zxcObj.offsetWidth < zxcPos(zxcDockAry[zxc0])[0]+zxcDockAry[zxc0].offsetWidth &&
  182.          zxcPos(zxcObj)[1]>zxcPos(zxcDockAry[zxc0])[1]&&
  183.          zxcPos(zxcObj)[1]+zxcObj.offsetHeight<zxcPos(zxcDockAry[zxc0])[1]+zxcDockAry[zxc0].offsetHeight){
  184.    return zxcDockAry[zxc0];
  185.   }
  186.  }
  187.  return false
  188. }
  189.  
  190. function zxcPos(zxc){
  191.  zxcl=zxc.offsetLeft;
  192.  zxct=zxc.offsetTop;
  193.  while(zxc.offsetParent!=null){
  194.   zxcp=zxc.offsetParent;
  195.   zxcl+=zxcp.offsetLeft;
  196.   zxct+=zxcp.offsetTop;
  197.   zxc=zxcp;
  198.  }
  199.  return [zxcl,zxct];
  200. }
  201.  
  202. document.onmousedown=zxcMouseDown;
  203. document.onmouseup=new Function('zxcMseUp();');
  204. window.onload=zxcInit;
Nov 18 '07 #1
1 1674
acoder
16,027 Expert Mod 8TB
Perhaps you may want to take a look at this and see if it helps you solve your problem.
Nov 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

18 posts views Thread by Niels | last post: by
15 posts views Thread by 50295 | last post: by
36 posts views Thread by Simon Wigzell | last post: by
4 posts views Thread by fcurvat | last post: by
1 post views Thread by newspost2000 | last post: by
10 posts views Thread by Paul Gorodyansky | last post: by
5 posts views Thread by Charlie | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.