How to Trick/Fool an Iframe to thinking its the TO

2019-02-28 02:36发布

问题:

I've created this frame busting code, and now for fun, I want to bust it. This code appears inside an iframe page:

(function() {
 if (window!=top) {
//Bust out of iframe below:
 top.location.replace(location);
 }
})();

And it busts out of the iframe.

I do not want to alter this code at all, but I want a workaround code to put in the PARENT of this iframe, so that the iframe can't detect that its an iframe, thus invalidating this frame-busting code.

In other words, how do I make the iframe think that it IS the top window (meaning window==top) Any workaround is appreciated!

回答1:

This is not in itself possible, but there are a number of techniques for disabling the effect of common framebustin techniques - one of them can be read about here.

It works by using the onunloadevent to 'cancel' the url-redirection by setting its location to a document returning a status code of 204.



标签: iframe window