I am trying to load a 3rd party website inside an iframe. However, the website has a “frame buster” script that causes it to break out of the iframe and take over the entire page resulting in the user leaving my site.
I found that using the following script will ask the user to confirm whether or not they want to leave my site.
window.onbeforeunload = function() { return false; }
If they select “Cancel” then the user stays on my site and the website will load itself in the iframe as it was intended. However, if the user says OK, then the breakout is successful and they are taken away from my site.
Is there any way to add a function that has the same effect of the “cancel” button on the onbeforeunload box?
If you press cancel everything works as it is intended so I am hoping someone might have a solution to this problem. Any ideas would be greatly appreciated.