0

I have a frame with a page from a different domain. Sometimes, that page likes to use a frame-buster to break out of its frame and hijack my entire page.

I have been experimenting with different ways to handle what happens when this frame wants to break out. What I have determined would be the best way to handle this is to use JavaScript to determine when the parent page url changes (via onunload) I want to direct the user back to my homepage or close the page altogether. I am a php dev and don't really ever use JavaScript.

I have tried using but that doesn't seem to work. Any ideas?

muncherelli
  • 2,887
  • 8
  • 39
  • 54

1 Answers1

0

you can use something like this:
<script>
window.onunload=function() {
return confirm('Are you sure you want to leave the current page?');
}
</script>

Pav
  • 2,288
  • 4
  • 22
  • 25
  • Eh I don't want to just ask the user if they want to leave the page, I want to redirect them to another page, maybe if they click yes? – muncherelli May 06 '11 at 03:07
  • please see http://stackoverflow.com/questions/2813455/is-it-possible-for-onunload-confirm-to-open-a-new-url-in-the-same-window – Pav May 06 '11 at 03:14
  • The parent frame still directs to the frame-busted page with that code. I tried something very similar with no avail. – muncherelli May 06 '11 at 03:15
  • what about this http://stackoverflow.com/questions/369498/how-to-prevent-iframe-from-redirecting-top-level-window – Pav May 06 '11 at 03:21