Javascript on twitter to prevent html page embedding

This is javascript that you can find at www.twitter.com (just click to see the source code) I 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 that this trick is to prevent other sites from wrapping twitter in other iframes. but I want to ask do we really need all this code? that you need to set the function to execute in 1 millisecond, one to execute in "onload" mode, and now.

Is it paranoia or is it really worth it?

Many benefits in advance Reg

+3
source share
1 answer

, , , . , , "" /, , . / , . /iframe, .

+2

Source: https://habr.com/ru/post/1739173/


All Articles