This javascript code snippet is extracted from www.twitter.com (simply click to view the source code). I have reformatted it for better readability:
if (window.top !== window.self) {
document.write = "";
window.top.location = window.self.location;
setTimeout(function() {
document.body.innerHTML = '';
}, 1);
window.self.onload = function(evt) {
document.body.innerHTML = '';
};
}
It seems this trick is implemented to prevent twitter from being enclosed in iframes on other sites. However, my question is: do we actually need all this code? What's the necessity of setting up one function to run after 1 millisecond, another at 'onload', and one immediately?
Is this level of caution justified or simply unnecessary paranoia?
Thank you in advance, Reg