/
callable_example.html
59 lines (59 loc) · 1.33 KB
/
callable_example.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
58
59
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>Callable HTMLCollection</title>
<link rel="Start" href="./">
<link rev="Section" href="api_design.html">
</head>
<body>
<form action="" id="a" name="d"><input type="text"></form>
<h3>Your Browser's Result:</h3>
<pre id="callableResult">-</pre>
<pre>
<script type="text/javascript">(function(){
var f = document.forms, isCallable = true,
callableResult = document.getElementById('callableResult');
try {
f(0);
} catch(ex) {
isCallable = false;
}
if(!isCallable) {
callableResult.firstChild.data = "form is not callable";
} else {
callableResult.firstChild.data =
["typeof f " + "\""+ (typeof f) + "\"",
"f('0') " + f('0'),
"f('a') " + f('a'),
"f('d') " + f('d')].join('\n');
}
})();</script>
</pre>
<hr>
<h3>Browser Results:</h3>
Firefox
<pre>form is not callable</pre>
Opera 9
<pre>
typeof f "object"
f('0') [object HTMLFormElement]
f('a') [object HTMLFormElement]
f('d') [object HTMLFormElement]
</pre>
IE6, IE7, IE8
<pre>
typeof f "object"
f('0') [object]
f('a') [object]
f('d') [object]
</pre>
Safari
<pre>
typeof f "function"
f('0') [object HTMLFormElement]
f('a') [object HTMLFormElement]
f('d') [object HTMLFormElement]
</pre>
</body>
</html>