This function is useful to determinate information about the page who host an iframe from the iframe.
function get_root(obj, current_ref) {
if(obj.parent.location.href != current_ref) {
return get_root(obj.parent, obj.location.href);
}
else {
return obj.location.href;
}
}
Usage:
get_root(window, window.location.href)
if(obj.parent.location.href != current_ref) {
return get_root(obj.parent, obj.location.href);
}
else {
return obj.location.href;
}
}
Usage:
get_root(window, window.location.href)
Credits to: 3xlstudio
http://snipplr.com/view/60285/ifram-get-parent/
Get Root – Find iframe parent location 
