mw = event.clientX; mh = event.clientY; dw = current.clientWidth; dh = current.clientHeight; //oh = document.body.scrollTop; oh = document.documentElement.scrollTop; current.style.top= oh + mh -5 ; current.style.left= mw -5 ; if ((mw+dw)>bw) current.style.left= bw - dw -5 ; } } function funs(o) { if(o.contains(event.toElement ) == false ) { o.style.display="none"; } } document.onclick=sorh