forked from jeresig/env-js
/
iframeN.html
57 lines (52 loc) · 2.44 KB
/
iframeN.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
* This file is a component of env.js,
* http://github.com/gleneivey/env-js/commits/master/README
* a Pure JavaScript Browser Environment
* Copyright 2009 John Resig, licensed under the MIT License
* http://www.opensource.org/licenses/mit-license.php
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en" dir="ltr" id="html">
<head>
<title>Document for testing arbitrary-depth IFRAME nesting in env.js</title>
</head>
<body onload="bodyOnloadHandler();">
<script>
window.top.numberNestedIframeLoads += 1;
function aPara(pId, pText, n){
var t = document.createTextNode(pText + " " + n);
var p = document.createElement('p');
p.setAttribute('id', pId + n);
p.appendChild(t);
document.getElementsByTagName('body')[0].appendChild(p);
}
window.onload = function(){ aPara("pCreatedWindowOnload",
"para window onload",
window.top.numberNestedIframeLoads);
window.top.winLoadCount += 1; }
function bodyOnloadHandler(){ aPara("pCreatedBodyOnload",
"para body onload",
window.top.numberNestedIframeLoads);
window.top.bodyLoadCount += 1; }
function iframeOnloadHandler(){ aPara("pCreatedIframeOnload",
"para iframe onload",
window.top.numberNestedIframeLoads);
window.top.frameLoadCount += 1; }
</script>
<p>
This document will be loaded into an IFRAME, and the following
JavaScript finds an element in the parent document that contains
the nesting level count, increments it, and then produces an
identical element with the result in this document.
<script>
var counterAsText = window.parent.document.
getElementById('nestingLevel').innerHTML;
var newCount = parseInt(counterAsText) + 1;
document.write('\x3cspan id="nestingLevel"\x3e' + newCount +
'\x3c/span\x3e');
</script>
</p>
</body>
</html>