Hey guys,
I am displaying an external website via an iFrame on my website. I am using the following code to detect if the iFrame tries to redirect the parent window:
This works 100% of the time in Firefox. It notifies me that the page is trying to redirect, and lets me choose to stay or follow the redirection.Code:<body> <script type="text/javascript"> var framekiller = true; window.onbeforeunload = function() { if(framekiller) { return "Stay on this page or leave the page to follow the URL."; } }; </script> <iframe id="page" style="height:400px;width:100%;border:0px solid black;" src="'.$safe_url.'">Hello</iframe> <script type="text/javascript"> document.getElementById("page").onload = function() { framekiller = false; }; </script> </body>
Now in Safari this seems to work about 1 every 8 times, or less. Can someone please help me understand why this happens and tell me how I can fix it?
Also, in Firefox it appears I can't display text within the redirection box warning, but in Safari (when it works) I can. Any idea why?
Thanks very much, you guys are always helpful.



Reply With Quote

Bookmarks