javascript on twitter to prevent embedding the html page.
- by Reginald
This is the javascript that you can find in www.twitter.com (just click to see the source code)
I have just reformatted it for clarity:
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 = '';
};
}
now I understand this trick is to prevent other sites to wrap twitter in other iframes.
but what I want to ask is
do we really need all of this code ?
what's the need of setting a function to execute in 1 millisecond, one to execute at 'onload'
and one now.
is that paranoia or is it really worth ?
Many THanks in advance
Reg