I am loading a website’s content in an iframe through a proxy on my server. If I add this javascript at the top of the file,
var top = "";
var parent = "";
I can successfully prevent the website from frame busting. How can I do this and still access functions in the parent window, like this:
parent.my_function('this is called from inside the iframe');
I’m not at all sure overwriting those variables necessarily prevents frame busting, but if it’s working for you, presumably to access
parentyou can do something like this:…and access
oldParentwithin the function.Separately, note that
and
…are both syntax errors. You use
varto declare variables, not properties of named objects.If you’re at global scope,
var topwould create a property onwindowif there weren’t already one, but if there’s one already (and there is), it’s a no-op and thevarportion is ignored entirely (the assignment portion is still processed). Absent syntax errors, your four lines boil down to:or
…which are equivalent if
topandparentexist onwindow(and they do).