Iframe to infinity

2019-01-20 12:14发布

问题:

If I have an HTML page, and in it I have an iframe that loads the page the iframe is on within it...

What will happen?

回答1:

nothing will happen due to restrictions. (the browser ain't -that- stupid anymore)



回答2:

For most browsers - as in Mozilla, Webkit et al. - nothing will happen because eventually there is a limit on the iframe nesting depth. Also any iframe with its SRC being set to the exact URL used by one of its parents will be treated to have no SRC URL at all (the iframe renders as a blank frame - as shown in the fiddle from the above comment: http://jsfiddle.net/tze8x/1/).

BUT for Internet Explorer different rules apply... If you add a simple iteration number as a query string to the nested iFrame's src IE - and we also tested this with the latest IE version 10 - just crashes :)

this.php

<html>
<head></head>
<body>
<iframe src="this.php?q=<?php echo (isset($_GET['q'])?$_GET['q']:1)+1?>" />
</body>
</html>


标签: html iframe