function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  
  whichDog=document.all.theLayer;
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}  
我是个菜鸟对于js不是很熟练,这是在网上找到的一段代码,但当我拖动滚动条的时候就会出现脚本错误,提示缺少对象,我测试了一下是因为whichDog这个对象造成的还望各位大虾能帮我解决