I have an iframe where the web page inside of the iframe runs a JavaScript redirect to a new page. On most browsers, the iframe is redirected to the new page. On Chrome however this script acts as a “frame breaker” and the entire page gets redirected. How do I make chrome act like the other browsers?
To Reproduce this effect on your machine:
-
Open this page: http://www.w3schools.com/html/tryit.asp?filename=tryhtml_iframe_height_width
-
Then replace the iframe source with this page:
src=”http://www.tizag.com/javascriptT/examples/timedelay.php”
Chrome supports the sandbox attribute which you can use to prevent the loaded page from breaking out of your iframe.
If you add
sandbox="allow-scripts"to the iframe in your example it works on Chrome.