/
form_dom_removal.html
53 lines (47 loc) · 1.23 KB
/
form_dom_removal.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
<!DOCTYPE HTML>
<html>
<head>
<title>Test element Removal</title>
<style type='text/css'>
.fail { background: #F33; }
.pass { background: #0f0; }
b { display: none; padding: 1px 3px;
font-family: monospace; white-space: pre;}
</style>
</head>
<body>
<form action="">
<input type="text" name="test">
</form>
<b id="failElements" class="fail">FAIL</b>
<b id="passElements" class="pass">PASS</b>
<strong>form.elements.test is null?</strong>
<div>
<b id="passForm" class="pass">PASS</b>
<b id="failForm" class="fail">FAIL</b>
<strong>form.test is null?</strong>
</div>
<script type="text/javascript">
var d = document,
form = d.forms[0],
display = "inline-block",
failElements = d.getElementById('failElements'),
passElements = d.getElementById('passElements'),
failForm = d.getElementById('failForm'),
passForm = d.getElementById('passForm');
// comment the following line to hide bug:
form.test;
while(form.lastChild){
form.removeChild(form.lastChild);
}
if(document.forms[0].elements.test )
failElements.style.display = display;
else
passElements.style.display = display;
if(document.forms[0].test )
failForm.style.display = display;
else
passForm.style.display = display;
</script>
</body>
</html>