Sorry for the late reply.
Can't it be done without the divs/forms/any element being pre-defined? I've hooked up a function to check if the moving div is inside any element here it is:
Code:
HTMLElement.prototype.getBoundingBox = function(){
var n = this;
return {top: n.offsetTop, left: n.offsetLeft, width: n.offsetWidth, height: n.offsetHeight, bottom: n.offsetTop + n.offsetHeight, right: n.offsetLeft + n.offsetWidth};
}
HTMLElement.prototype.isInside = function(el){
var st = document.getElementById(el).getBoundingBox();
var ts = this.getBoundingBox();
if(ts.right > st.left && ts.left < st.right && ts.bottom > st.top && ts.top < st.bottom){
return true;
} else {
return false;
}
}
Bookmarks