lots-of-iframes.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. var maxNumberOfFrames = 100;
  5. function createIFrames() {
  6. var str = "<div id=\"status\"></div>";
  7. for (var i = 0; i < maxNumberOfFrames + 1; i++) {
  8. str += "<iframe id=\"i" + i + "\" src=\"data:text/html,iframe_" + i + "\"></iframe>";
  9. }
  10. document.getElementsByTagName("body")[0].innerHTML = str;
  11. var results = "";
  12. var f = document.getElementById("i" + (maxNumberOfFrames - 1));
  13. if (f && f.contentWindow) {
  14. results += "Sucessfully created " + maxNumberOfFrames + " frames.<br>";
  15. } else {
  16. results += "Failed to create " + maxNumberOfFrames + " frames.<br>";
  17. }
  18. var g = document.getElementById("i" + maxNumberOfFrames);
  19. if (g && g.contentWindow) {
  20. results += "Failed to block creation of frame number " + (maxNumberOfFrames + 1) + ".";
  21. } else {
  22. results += "Successfully blocked creation of frame number " + (maxNumberOfFrames + 1) + ".";
  23. }
  24. document.getElementById("status").innerHTML = results;
  25. }
  26. </script>
  27. </head>
  28. <body onLoad="createIFrames()">
  29. </body>
  30. </html>