What is this check. is it an iframe check?

if(window.top!==window.self){document.write="";
window.top.location=window.self.location;
setTimeout(function(){document.body.innerHTML=""},1);
window.self.onload=function(){document.body.innerHTML=""}};

Does this mean that the page is not displayed inside the iframe?

+3
source share
4 answers

Yes, it looks like this attempt at a script makes itself a parent frame, if it hasn't been. AS Pointy said that they do not always work. Javascript cannot “escape” from its owner document in most browsers if it has not created this document. Or if the page containing Javascript was loaded dynamically so that the policy of the same domain is not valid. (This is probably not the case if your site is in an iframe / frame). In the case of a page that opens inside another, the script should not have access to modify the parent document.

, , .

if(window.top!==window.self){ // is the outermost document not this document?
  document.write=""; // write an empty text node to the document. (not sure why)
  window.top.location=window.self.location; // set the parent document location to this document location.
  setTimeout( function(){document.body.innerHTML=""}, 1); // after 1 millisecond make this document HTML empty. (Probably a memory leak fix)
  window.self.onload = function(){document.body.innerHTML=""} // Another memory leak fix to clear the current document when it is done loading.
};
+3

"frame buster". .

+1

window.top means the topmost window in your browser. In simple words, this is a browser window.

The code seems to clear all frames with a space.

0
source

Does this mean that the page is not displayed inside the iframe?

An iframeor frame, yes. He is trying to break free.

0
source

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


All Articles