Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /smlnj-lib/branches/rt-transition/HTML4/tests/scripts.html
ViewVC logotype

Annotation of /smlnj-lib/branches/rt-transition/HTML4/tests/scripts.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4071 - (view) (download) (as text)

1 : jhr 4071 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 :     <html lang="en-US">
3 :     <title>Scripts [Robin&rsquo;s HTML 4.0 Conformance Test]</title>
4 :     <meta name="description" content="Test your Web browser&rsquo;s support for scripting elements. Part of Robin&rsquo;s HTML 4.0 Conformance Test.">
5 :     <meta name="keywords" content="scripts, JavaScript, ECMAScript, VBScript, tcl, perlscript, COBOLScript, MIME types, application/x-javascript, application/javascript, application/ecmascript, text/javascript, text/ecmascript, noscript, defer">
6 :     <meta name="DC.Creator" content="Lionheart, Robin">
7 :     <link rel="home" href="http://www.robinlionheart.com/" title="RobinLionheart.com">
8 :     <link rel="first" href="./" title="Robin&rsquo;s HTML 4.0 Test">
9 :     <link rel="prev" href="quote" title="Quotations">
10 :     <link rel="next" href="tables" title="Tables">
11 :     <link rel="glossary" href="glossary" title="Glossary">
12 :     <link rel="author" href="http://www.robinlionheart.com/robin/" title="Robin Lionheart">
13 :    
14 :     <link rel="stylesheet" href="/style/linkcolors.css" type="text/css" media="screen, tv, projection">
15 :     <link rel="stylesheet" href="html4.css" type="text/css" media="screen, tv, projection" title="Conformance Test">
16 :     <link rel="icon" href="/images/icons/htmltest.png" type="image/png">
17 :    
18 :    
19 :     <div id="navbar">
20 :     <ul class="nl" id="breadcrumbs"><li><a href="./" rel="first">Robin&rsquo;s HTML 4.0 Test</a><ul><li>Scripts</li></ul></li></ul>
21 :     <ul class="nl">
22 :     <li><a href="./" rel="first" accesskey="1" title="First: Robin&rsquo;s HTML 4.0 Test">&#8676;<strong>1</strong>st</a></li>
23 :     <li><a href="quote" rel="prev" accesskey="P" title="Prior: Quotations">&#8592;<strong>P</strong>rior</a></li>
24 :     <li><a href="tables" rel="next" accesskey="N" title="Next: Tables"><strong>N</strong>ext&#8594;</a></li>
25 :     </ul>
26 :     </div>
27 :    
28 :     <h1>Scripts (<a class="specsect" href="http://www.w3.org/TR/html4/interact/scripts.html" title="HTML 4.0 Specification">&sect;18</a>)</h1>
29 :    
30 :     <div class="section" id="noscript">
31 :     <h2>Noscript nitpicking (<a class="specsect" href="http://www.w3.org/TR/html4/interact/scripts.html#h-18.3.1" title="HTML 4.0 Specification">&sect;18.3.1</a>)</h2>
32 :    
33 :     <div class="bodytext">
34 :     <p>An <abbr>HTML</abbr> 4.0 compliant Web browser that cannot render scripts <em>must</em> render contents of a <dfn><a class="specsect" href="http://www.w3.org/TR/html4/interact/scripts.html#edef-noscript" title="HTML 4.0 Specification: 18 Scripts"><code class="element">&lt;noscript></code></a></dfn> element. Compliant Web browsers that can render scripts <em>should</em> render contents of a <code class="element">&lt;noscript></code> element when scripting is disabled.</p>
35 :     <p>The standard also says Web browsers should render <code class="element">&lt;noscript></code> after a script it could not render earlier in a document. <span class="note">This feature is of questionable desirability, and is rarely observed in practice.</span></p>
36 :     </div>
37 :    
38 :     <div class="illo">
39 :     <h3>Example:</h3>
40 :    
41 :     <div class="blockcode">
42 :     <em class="html">&lt;script <strong class="tested">type="application/x-fakescript"</strong>></em>&lt;!--<br>
43 :     <div class="indent">
44 :     // There is no such thing as FakeScript.<br>
45 :     alert("I should not be running a FakeScript script!");<br>
46 :     document.writeln('&lt;p>&lt;em>This Web browser executed a FakeScript script.&lt;\/em>&lt;\/p>');<br>
47 :     // --><br>
48 :     </div>
49 :     <em class="html">&lt;/script></em><br>
50 :     <em class="html4"><strong class="tested">&lt;noscript></strong></em><br>
51 :     <div class="indent">
52 :     <em class="html">&lt;p></em>Technically, your Web browser should render this line whether or not scripting is enabled.<em class="html">&lt;/p></em><br>
53 :     </div>
54 :     <em class="html4"><strong class="tested">&lt;/noscript></strong></em>
55 :     </div>
56 :    
57 :     <h4 class="resultheader">Your Web browser renders it like this:</h4>
58 :     <div class="results" id="result1">
59 :     <script type="application/x-fakescript"><!--
60 :     // There is no such thing as FakeScript.
61 :     alert("I should not be running a FakeScript script!");
62 :     document.writeln("<p><em>This Web browser executed a FakeScript script.<\/em><\/p>");
63 :     // -->
64 :     </script>
65 :     <noscript>
66 :     <p>Technically, your Web browser should render this line whether or not scripting is enabled.</p>
67 :     </noscript>
68 :     </div>
69 :     </div>
70 :     </div>
71 :    
72 :    
73 :    
74 :    
75 :    
76 :    
77 :    
78 :    
79 :     <div class="section" id="type">
80 :     <h2>Content types</h2>
81 :    
82 :     <div class="bodytext">
83 :     <p>The <a class="specsect" href="http://www.w3.org/TR/html4/interact/scripts.html#adef-type-SCRIPT" title="HTML 4.0 Specification: 18 Scripts"><code class="attribute">type</code></a> attribute specifies the <a href="glossary#content_type" class="local" title="Glossary" rel="glossary">content type</a> of a script (that is, what language the script is in).</p>
84 :    
85 :     <p class="note">On 27 June 2005, the <abbr>IETF</abbr> has at last <a href="http://www1.ietf.org/mail-archive/web/ietf-announce/current/msg01349.html">registered content types for JavaScript</a>, <strong><code class="content_type">application/javascript</code></strong>, <strong><code class="content_type">application/ecmascript</code></strong>, <strong><code class="content_type">text/javascript</code></strong> (marked obsolete), and <strong><code class="content_type">text/ecmascript</code></strong> (marked obsolete). Examples in the <abbr>HTML</abbr> 4.0 specification incorrectly used then&#8208;unregistered content type <code class="content_type">text/javascript</code> for JavaScript instead of well&#8208;established though unofficial content type <strong><code class="content_type">application/x-javascript</code></strong>. Using a subtype of <code class="content_type">text</code> for code to be executed instead of text for humans to read was a mistake and can cause problems. Examples also incorrectly use <code class="content_type">text/vbscript</code> (instead of <code class="content_type">application/x-vbscript</code>) and <code class="content_type">text/tcl</code> (instead of <code class="content_type">application/x-tcl</code>).</p>
86 :     <p class="note">The <code class="attribute">type</code> attribute replaces the ill&#8208;defined <code class="attribute">language</code> attribute used by older browsers. <abbr>HTML</abbr> 4.0 simultaneously introduces <code class="attribute">language</code> for compatibility, and deprecates it in favor of <code class="attribute">type</code>.</p>
87 :     </div>
88 :    
89 :     <div class="illo">
90 :     <h3>Example:</h3>
91 :    
92 :     <div class="blockcode">
93 :     <em class="html">&lt;div <em class="html4">id="validtypes"</em>></em><br>
94 :     <div class="indent">
95 :     <em class="html">&lt;p></em>This Web browser executes scripts with these valid content types:<em class="html">&lt;/p></em><br>
96 :     <br>
97 :     <em class="html">&lt;script <strong class="tested">type="application/javascript"</strong>></em>&lt;!--<br>
98 :     <div class="indent">
99 :     // Correct but rarely supported type for JavaScript<br>
100 :    
101 :     if (document.createTextNode) {<br>
102 :     <div class="indent">
103 :     // the standards-compliant DOM way<br>
104 :     var newPara = document.createElement("p");<br><br>
105 :     var textNode = document.createTextNode("\u2022 ");<br>
106 :     newPara.appendChild(textNode);<br><br>
107 :     var codeNode = document.createElement("code");<br>
108 :     newPara.appendChild(codeNode);<br><br>
109 :     textNode = document.createTextNode("application/javascript");<br>
110 :     codeNode.appendChild(textNode);<br><br>
111 :     var div = document.getElementById("validtypes");<br>
112 :     div.appendChild(newPara);<br>
113 :     </div>
114 :     } else {<br>
115 :     <div class="indent">
116 :     // the old DHTML way<br>
117 :     document.writeln("&lt;p><em class="html4"><em class="entity">&amp;bull;</em></em> &lt;code>application/javascript&lt;\/code> &lt;i>(without the &lt;abbr>DOM&lt;\/abbr>)&lt;\/i>&lt;\/p>");<br>
118 :     </div>
119 :     }<br>
120 :     // --><br>
121 :     </div>
122 :     <em class="html">&lt;/script></em><br>
123 :     <em class="html">&lt;script <strong class="tested">type="application/ecmascript"</strong>></em>&lt;!--<br>
124 :     <div class="indent">
125 :     // Correct but rarely supported type for ECMAscript<br>
126 :     // Proposed by ECMAScript standard<br>
127 :    
128 :     var newPara = document.createElement("p");<br><br>
129 :     var textNode = document.createTextNode("\u2022 ");<br>
130 :     newPara.appendChild(textNode);<br><br>
131 :     var codeNode = document.createElement("code");<br>
132 :     newPara.appendChild(codeNode);<br><br>
133 :     textNode = document.createTextNode("application/ecmascript");<br>
134 :     codeNode.appendChild(textNode);<br><br>
135 :     var div = document.getElementById("validtypes");<br>
136 :     div.appendChild(newPara);<br>
137 :    
138 :     // --><br>
139 :     </div>
140 :     <em class="html">&lt;/script></em><br>
141 :     <em class="html">&lt;script <strong class="tested">type="application/x-vbscript"</strong>></em>&lt;!--<br>
142 :     <div class="indent">
143 :     ' Correct unregistered type for VBScript<br>
144 :     option explicit<br>
145 :     dim newPara, textNode, codeNode, div<br><br>
146 :     set newPara = document.createElement("p")<br>
147 :     set textNode = document.createTextNode(ChrW(&amp;H2022) + " ")<br>
148 :     newPara.appendChild(textNode)<br><br>
149 :     set codeNode = document.createElement("code")<br>
150 :     newPara.appendChild(codeNode)<br><br>
151 :     set textNode = document.createTextNode("application/x-vbscript")<br>
152 :     codeNode.appendChild(textNode)<br><br>
153 :     set div = document.getElementById("validtypes")<br>
154 :     div.appendChild(newPara)<br>
155 :     ' --><br>
156 :     </div>
157 :     <em class="html">&lt;/script></em><br>
158 :     <em class="html">&lt;script <strong class="tested">type="application/x-tcl"</strong>></em>&lt;!--<br>
159 :     <div class="indent">
160 :     # Correct unregistered media type for Tcl.<br>
161 :     # I know of no Web browsers that run Tcl.<br>
162 :     document writeln "&lt;p><em class="html4"><em class="entity">&amp;bull;</em></em> &lt;i>&lt;code>text/tcl&lt;\/code>&lt;\/i>&lt;\/p>"<br>
163 :     # --><br>
164 :     </div>
165 :     <em class="html">&lt;/script></em><br>
166 :     <em class="html">&lt;script <strong class="tested">type="application/x-perlscript"</strong>></em>&lt;!--<br>
167 :     <div class="indent">
168 :     # Correct unregistered media type for PerlScript<br>
169 :     # I know of no Web browsers that run PerlScript,<br>
170 :     # but some Web servers can generate page content with it.<br>
171 :     $window->document->writeln("&lt;p><em class="html4"><em class="entity">&amp;bull;</em></em> &lt;code>application/x-perlscript&lt;\/code>&lt;\/p>");<br>
172 :     # --><br>
173 :     </div>
174 :     <em class="html">&lt;/script></em><br>
175 :     <em class="html">&lt;script <strong class="tested">type="application/x-cobolscript"</strong>></em>&lt;!--<br>
176 :     <div class="indent">
177 :     * You youngsters are so spoiled.<br>
178 :     * Back in the day, we wrote Web pages on punched cards...<br>
179 :     &nbsp;IDENTIFICATION DIVISION.<br>
180 :     &nbsp;PROGRAM-ID. Test_COBOLScript.<br>
181 :     &nbsp;DATA DIVISION.<br>
182 :     &nbsp;WORKING-STORAGE DIVISION.<br>
183 :     &nbsp;PROCEDURE DIVISION.<br>
184 :     <div class="indent">
185 :     &nbsp;INVOKE HOST "document.write" USING BY VALUE "&lt;p><em class="html4"><em class="entity">&amp;bull;</em></em> &lt;code>application/x-cobolscript&lt;".<br>
186 :     &nbsp;INVOKE HOST "document.write" USING BY VALUE "/code>&lt;".<br>
187 :     &nbsp;INVOKE HOST "document.write" USING BY VALUE "/p>"<br>
188 :     </div>
189 :     &nbsp;END PROGRAM.<br>
190 :     * --><br>
191 :     </div>
192 :     <em class="html">&lt;/script></em><br>
193 :     </div>
194 :     <em class="html">&lt;/div></em>
195 :     <br>
196 :     <em class="html">&lt;div <em class="html4">id="obsoletetypes"</em>></em><br>
197 :     <div class="indent">
198 :     <em class="html">&lt;p></em>This Web browser executes scripts with these valid, obsolete content types:<em class="html">&lt;/p></em><br>
199 :     <br>
200 :     <em class="html">&lt;script <strong class="tested">type="text/javascript"</strong>></em>&lt;!--<br>
201 :     <div class="indent">
202 :     // Historically misused for JavaScript<br>
203 :     // Registered as obsolete in 2005<br>
204 :     if (document.createTextNode) {<br>
205 :     <div class="indent">
206 :     // the standards-compliant DOM way<br>
207 :     var newPara = document.createElement("p");<br><br>
208 :     var textNode = document.createTextNode("\u2022 ");<br>
209 :     newPara.appendChild(textNode);<br><br>
210 :     var codeNode = document.createElement("code");<br>
211 :     newPara.appendChild(codeNode);<br><br>
212 :     textNode = document.createTextNode("text/javascript");<br>
213 :     codeNode.appendChild(textNode);<br><br>
214 :     var div = document.getElementById("obsoletetypes");<br>
215 :     div.appendChild(newPara);<br>
216 :     </div>
217 :     } else {<br>
218 :     <div class="indent">
219 :     // the old DHTML way<br>
220 :     document.writeln("&lt;p><em class="html4"><em class="entity">&amp;bull;</em></em> &lt;code>text/javascript&lt;\/code> &lt;i>(without the &lt;abbr>DOM&lt;\/abbr>)&lt;\/i>&lt;\/p>");<br>
221 :     </div>
222 :     }<br>
223 :     // --><br>
224 :     </div>
225 :     <em class="html">&lt;/script></em><br>
226 :     <em class="html">&lt;script <strong class="tested">type="text/ecmascript"</strong>></em>&lt;!--<br>
227 :     <div class="indent">
228 :     // Poorly-chosen default for scripts in SVG<br>
229 :     // Registered as obsolete in 2005<br>
230 :    
231 :     var newPara = document.createElement("p");<br><br>
232 :     var textNode = document.createTextNode("\u2022 ");<br>
233 :     newPara.appendChild(textNode);<br><br>
234 :     var codeNode = document.createElement("code");<br>
235 :     newPara.appendChild(codeNode);<br><br>
236 :     textNode = document.createTextNode("text/ecmascript");<br>
237 :     codeNode.appendChild(textNode);<br><br>
238 :     var div = document.getElementById("obsoletetypes");<br>
239 :     div.appendChild(newPara);<br>
240 :    
241 :     // --><br>
242 :     </div>
243 :     <em class="html">&lt;/script></em><br>
244 :     <em class="html">&lt;script <strong class="tested">type="application/x-javascript"</strong>></em>&lt;!--<br>
245 :     <div class="indent">
246 :     // Widely-accepted unregistered type for JavaScript<br>
247 :     // Used since the days of Netscape 3.x<br>
248 :     if (document.createTextNode) {<br>
249 :     <div class="indent">
250 :     // the standards-compliant DOM way<br>
251 :     var newPara = document.createElement("p");<br><br>
252 :     var textNode = document.createTextNode("\u2022 ");<br>
253 :     newPara.appendChild(textNode);<br><br>
254 :     var codeNode = document.createElement("code");<br>
255 :     newPara.appendChild(codeNode);<br><br>
256 :     textNode = document.createTextNode("application/x-javascript");<br>
257 :     codeNode.appendChild(textNode);<br><br>
258 :     var div = document.getElementById("obsoletetypes");<br>
259 :     div.appendChild(newPara);<br>
260 :     </div>
261 :     } else {<br>
262 :     <div class="indent">
263 :     // the old DHTML way<br>
264 :     document.writeln("&lt;p><em class="html4"><em class="entity">&amp;bull;</em></em> &lt;code>application/x-javascript&lt;\/code> &lt;i>(without the &lt;abbr>DOM&lt;\/abbr>)&lt;\/i>&lt;\/p>");<br>
265 :     </div>
266 :     }<br>
267 :     // --><br>
268 :     </div>
269 :     <em class="html">&lt;/script></em><br>
270 :     <em class="html">&lt;script <strong class="tested">type="application/x-ecmascript"</strong>></em>&lt;!--<br>
271 :     <div class="indent">
272 :     // Recommended by ECMAScript standard<br>
273 :     // To be replaced by application/ecmascript<br>
274 :    
275 :     var newPara = document.createElement("p");<br><br>
276 :     var textNode = document.createTextNode("\u2022 ");<br>
277 :     newPara.appendChild(textNode);<br><br>
278 :     var codeNode = document.createElement("code");<br>
279 :     newPara.appendChild(codeNode);<br><br>
280 :     textNode = document.createTextNode("application/x-ecmascript");<br>
281 :     codeNode.appendChild(textNode);<br><br>
282 :     var div = document.getElementById("obsoletetypes");<br>
283 :     div.appendChild(newPara);<br>
284 :    
285 :     // --><br>
286 :     </div>
287 :     <em class="html">&lt;/script></em><br>
288 :     </div>
289 :     <em class="html">&lt;/div></em>
290 :     <br>
291 :     <em class="html">&lt;div <em class="html4">id="invalidtypes"</em>></em><br>
292 :     <div class="indent">
293 :     <em class="html">&lt;p></em>This Web browser executes scripts with these unregistered content types:<em class="html">&lt;/p></em><br>
294 :     <br>
295 :     <em class="html">&lt;script <strong class="tested">type="text/fakescript"</strong>></em>&lt;!--<br>
296 :     <div class="indent">
297 :     alert("I should not be running a text/fakescript script!");<br>
298 :     document.writeln('&lt;p><em class="html4"><em class="entity">&amp;bull;</em></em> &lt;em>text/fakescript&lt;\/em>&lt;\/p>');<br>
299 :     // --><br>
300 :     </div>
301 :     <em class="html">&lt;/script></em><br>
302 :     <em class="html">&lt;script <strong class="tested">type="text/jscript"</strong>></em>&lt;!--<br>
303 :     <div class="indent">
304 :     // Microsoft's proprietary version<br>
305 :    
306 :     if (document.createTextNode) {<br>
307 :     <div class="indent">
308 :     // the standards-compliant DOM way<br>
309 :     var newPara = document.createElement("p");<br><br>
310 :     var textNode = document.createTextNode("\u2022 ");<br>
311 :     newPara.appendChild(textNode);<br><br>
312 :     var codeNode = document.createElement("code");<br>
313 :     newPara.appendChild(codeNode);<br><br>
314 :     textNode = document.createTextNode("text/jscript");<br>
315 :     codeNode.appendChild(textNode);<br><br>
316 :     var div = document.getElementById("invalidtypes");<br>
317 :     div.appendChild(newPara);<br>
318 :     </div>
319 :     } else {<br>
320 :     <div class="indent">
321 :     // the old DHTML way<br>
322 :     document.writeln("&lt;p><em class="html4"><em class="entity">&amp;bull;</em></em> &lt;code>text/jscript&lt;\/code> &lt;i>(without the &lt;abbr>DOM&lt;\/abbr>)&lt;\/i>&lt;\/p>");<br>
323 :     </div>
324 :     }<br>
325 :     // --><br>
326 :     </div>
327 :     <em class="html">&lt;/script></em><br>
328 :     <em class="html">&lt;script <strong class="tested">type="text/livescript"</strong>></em>&lt;!--<br>
329 :     <div class="indent">
330 :     // iCab's alias<br>
331 :    
332 :     if (document.createTextNode) {<br>
333 :     <div class="indent">
334 :     // the standards-compliant DOM way<br>
335 :     var newPara = document.createElement("p");<br><br>
336 :     var textNode = document.createTextNode("\u2022 ");<br>
337 :     newPara.appendChild(textNode);<br><br>
338 :     var codeNode = document.createElement("code");<br>
339 :     newPara.appendChild(codeNode);<br><br>
340 :     textNode = document.createTextNode("text/livescript");<br>
341 :     codeNode.appendChild(textNode);<br><br>
342 :     var div = document.getElementById("invalidtypes");<br>
343 :     div.appendChild(newPara);<br>
344 :     </div>
345 :     } else {<br>
346 :     <div class="indent">
347 :     // the old DHTML way<br>
348 :     document.writeln("&lt;p><em class="html4"><em class="entity">&amp;bull;</em></em> &lt;code>text/livescript&lt;\/code> &lt;i>(without the &lt;abbr>DOM&lt;\/abbr>)&lt;\/i>&lt;\/p>");<br>
349 :     </div>
350 :     }<br>
351 :     // --><br>
352 :     </div>
353 :     <em class="html">&lt;/script></em><br>
354 :     <em class="html">&lt;script <strong class="tested">type="text/vbscript"</strong>></em>&lt;!--<br>
355 :     <div class="indent">
356 :    
357 :     option explicit<br>
358 :     dim newPara, textNode, codeNode, div<br><br>
359 :     set newPara = document.createElement("p")<br>
360 :     set textNode = document.createTextNode(ChrW(&amp;H2022) + " ")<br>
361 :     newPara.appendChild(textNode)<br><br>
362 :     set codeNode = document.createElement("code")<br>
363 :     newPara.appendChild(codeNode)<br><br>
364 :     set textNode = document.createTextNode("text/vbscript")<br>
365 :     codeNode.appendChild(textNode)<br><br>
366 :     set div = document.getElementById("invalidtypes")<br>
367 :     div.appendChild(newPara)<br>
368 :     ' --><br>
369 :     </div>
370 :     <em class="html">&lt;/script></em><br>
371 :     <em class="html">&lt;script <strong class="tested">type="text/vbs"</strong>></em>&lt;!--<br>
372 :     <div class="indent">
373 :    
374 :     option explicit<br>
375 :     dim newPara, textNode, codeNode, div<br><br>
376 :     set newPara = document.createElement("p")<br>
377 :     set textNode = document.createTextNode(ChrW(&amp;H2022) + " ")<br>
378 :     newPara.appendChild(textNode)<br><br>
379 :     set codeNode = document.createElement("code")<br>
380 :     newPara.appendChild(codeNode)<br><br>
381 :     set textNode = document.createTextNode("text/vbs")<br>
382 :     codeNode.appendChild(textNode)<br><br>
383 :     set div = document.getElementById("invalidtypes")<br>
384 :     div.appendChild(newPara)<br>
385 :     ' --><br>
386 :     </div>
387 :     <em class="html">&lt;/script></em><br>
388 :     <em class="html">&lt;script <strong class="tested">type="text/tcl"</strong>></em>&lt;!--<br>
389 :     <div class="indent">
390 :     # I know of no Web browsers that run Tcl.<br>
391 :     # The standard mentions text/tcl as an example value<br>
392 :     # for the Content-Script-Type header.<br>
393 :     document writeln "&lt;p><em class="html4"><em class="entity">&amp;bull;</em></em> &lt;i>&lt;code>text/tcl&lt;\/code>&lt;\/i>&lt;\/p>"<br>
394 :     # --><br>
395 :     </div>
396 :     <em class="html">&lt;/script></em><br>
397 :     </div>
398 :     <em class="html">&lt;/div></em>
399 :     </div>
400 :    
401 :     <h4 class="resultheader">Your Web browser renders it like this:</h4>
402 :     <div class="results" id="result2">
403 :     <div id="validtypes">
404 :     <p>This Web browser executes scripts with these valid content types:</p>
405 :    
406 :     <script type="application/javascript"><!--
407 :     // Correct but rarely supported type for JavaScript
408 :    
409 :     if (document.createTextNode) {
410 :     // the standards-compliant DOM way
411 :     var newPara = document.createElement("p");
412 :    
413 :     var textNode = document.createTextNode("\u2022 ");
414 :     newPara.appendChild(textNode);
415 :    
416 :     var codeNode = document.createElement("code");
417 :     newPara.appendChild(codeNode);
418 :    
419 :     textNode = document.createTextNode("application/javascript");
420 :     codeNode.appendChild(textNode);
421 :    
422 :     var div = document.getElementById("validtypes");
423 :     div.appendChild(newPara);
424 :     } else {
425 :     // the old DHTML way
426 :     document.writeln("<p>&bull; <code>application/javascript<\/code> <i>(without the <abbr>DOM<\/abbr>)<\/i><\/p>");
427 :     }
428 :     // -->
429 :     </script>
430 :     <script type="application/ecmascript"><!--
431 :     // Correct but rarely supported type for ECMA script
432 :     // Proposed by ECMAScript standard
433 :    
434 :     var newPara = document.createElement("p");
435 :    
436 :     var textNode = document.createTextNode("\u2022 ");
437 :     newPara.appendChild(textNode);
438 :    
439 :     var codeNode = document.createElement("code");
440 :     newPara.appendChild(codeNode);
441 :    
442 :     textNode = document.createTextNode("application/ecmascript");
443 :     codeNode.appendChild(textNode);
444 :    
445 :     var div = document.getElementById("validtypes");
446 :     div.appendChild(newPara);
447 :    
448 :     // -->
449 :     </script>
450 :     <script type="application/x-tcl"><!--
451 :     # The correct type for Tcl.<br>
452 :     # I know of no Web browsers that run Tcl.<br>
453 :     document write "<p>&bull; <code>text/tcl<\/code><\/p>"
454 :     # -->
455 :     </script>
456 :     <script type="application/x-vbscript"><!--
457 :     ' The correct type for VBScript
458 :     document.writeln "<p>&bull; <code>text/vbscript<", "/code><", "/p>"
459 :     ' -->
460 :     </script>
461 :     <script type="application/x-perlscript"><!--
462 :     # The correct type for PerlScript
463 :     # I know of no Web browsers that run PerlScript,
464 :     # but some Web servers can generate page content with it.
465 :     $window->document->writeln("<p>&bull; <code>application/x-perlscript<\/code><\/p>");
466 :     # -->
467 :     </script>
468 :     <script type="application/x-cobolscript"><!--
469 :     * You youngsters are so spoiled.
470 :     * Back in the day, we wrote Web pages on punched cards...
471 :     IDENTIFICATION DIVISION.
472 :     PROGRAM-ID. Test_COBOLScript.
473 :     DATA DIVISION.
474 :     WORKING-STORAGE DIVISION.
475 :     PROCEDURE DIVISION.
476 :     INVOKE HOST "document.write" USING BY VALUE "<p>&bull; <code>application/x-cobolscript<".
477 :     INVOKE HOST "document.write" USING BY VALUE "/code><".
478 :     INVOKE HOST "document.write" USING BY VALUE "/p>"
479 :     END PROGRAM.
480 :     * -->
481 :     </script>
482 :     </div>
483 :     <div id="obsoletetypes">
484 :     <p>This Web browser executes scripts with these valid, obsolete content types:</p>
485 :    
486 :     <script type="text/javascript"><!--
487 :     // Historically misused for JavaScript
488 :     // Registered as obsolete in 2005
489 :     if (document.createTextNode) {
490 :     // the standards-compliant DOM way
491 :     var newPara = document.createElement("p");
492 :    
493 :     var textNode = document.createTextNode("\u2022 ");
494 :     newPara.appendChild(textNode);
495 :    
496 :     var codeNode = document.createElement("code");
497 :     newPara.appendChild(codeNode);
498 :    
499 :     textNode = document.createTextNode("text/javascript");
500 :     codeNode.appendChild(textNode);
501 :    
502 :     var div = document.getElementById("obsoletetypes");
503 :     div.appendChild(newPara);
504 :     } else {
505 :     // the old DHTML way
506 :     document.writeln("<p>&bull; <code>text/javascript<\/code> <i>(without the <abbr>DOM<\/abbr>)<\/i><\/p>");
507 :     }
508 :     // -->
509 :     </script>
510 :     <script type="text/ecmascript"><!--
511 :     // Poorly-chosen default for scripts in SVG
512 :     // Registered as obsolete in 2005
513 :    
514 :     var newPara = document.createElement("p");
515 :    
516 :     var textNode = document.createTextNode("\u2022 ");
517 :     newPara.appendChild(textNode);
518 :    
519 :     var codeNode = document.createElement("code");
520 :     newPara.appendChild(codeNode);
521 :    
522 :     textNode = document.createTextNode("text/ecmascript");
523 :     codeNode.appendChild(textNode);
524 :    
525 :     var div = document.getElementById("obsoletetypes");
526 :     div.appendChild(newPara);
527 :    
528 :     // -->
529 :     </script>
530 :     <script type="application/x-javascript"><!--
531 :     // Widely-accepted unregistered type for JavaScript
532 :     // Used since the days of Netscape 3.x
533 :     if (document.createTextNode) {
534 :     // the standards-compliant DOM way
535 :     var newPara = document.createElement("p");
536 :    
537 :     var textNode = document.createTextNode("\u2022 ");
538 :     newPara.appendChild(textNode);
539 :    
540 :     var codeNode = document.createElement("code");
541 :     newPara.appendChild(codeNode);
542 :    
543 :     textNode = document.createTextNode("application/x-javascript");
544 :     codeNode.appendChild(textNode);
545 :    
546 :     var div = document.getElementById("obsoletetypes");
547 :     div.appendChild(newPara);
548 :     } else {
549 :     // the old DHTML way
550 :     document.writeln("<p>&bull; <code>application/x-javascript<\/code> <i>(without the <abbr>DOM<\/abbr>)<\/i><\/p>");
551 :     }
552 :     // -->
553 :     </script>
554 :     <script type="application/x-ecmascript"><!--
555 :     // Recommended by ECMAScript standard
556 :     // To be replaced by application/ecmascript
557 :    
558 :     var newPara = document.createElement("p");
559 :    
560 :     var textNode = document.createTextNode("\u2022 ");
561 :     newPara.appendChild(textNode);
562 :    
563 :     var codeNode = document.createElement("code");
564 :     newPara.appendChild(codeNode);
565 :    
566 :     textNode = document.createTextNode("application/x-ecmascript");
567 :     codeNode.appendChild(textNode);
568 :    
569 :     var div = document.getElementById("obsoletetypes");
570 :     div.appendChild(newPara);
571 :    
572 :     // -->
573 :     </script>
574 :     </div>
575 :     <div id="invalidtypes">
576 :     <p>This Web browser executes scripts with these unregistered content types:</p>
577 :    
578 :     <script type="text/fakescript"><!--
579 :     alert("I should not be running a text/fakescript script!");
580 :     document.writeln("<p>&bull; <em>text/fakescript<\/em><\/p>");
581 :     // -->
582 :     </script>
583 :     <script type="text/jscript"><!--
584 :     // MicroSoft's proprietary version
585 :    
586 :     if (document.createTextNode) {
587 :     // the standards-compliant DOM way
588 :     var newPara = document.createElement("p");
589 :    
590 :     var textNode = document.createTextNode("\u2022 ");
591 :     newPara.appendChild(textNode);
592 :    
593 :     var codeNode = document.createElement("code");
594 :     newPara.appendChild(codeNode);
595 :    
596 :     textNode = document.createTextNode("text/jscript");
597 :     codeNode.appendChild(textNode);
598 :    
599 :     var div = document.getElementById("invalidtypes");
600 :     div.appendChild(newPara);
601 :     } else {
602 :     // the old DHTML way
603 :     document.writeln("<p>&bull; <code>text/jscript<\/code> <i>(without the <abbr>DOM<\/abbr>)<\/i><\/p>");
604 :     }
605 :     // -->
606 :     </script>
607 :     <script type="text/livescript"><!--
608 :     // iCab's alias
609 :    
610 :     if (document.createTextNode) {
611 :     // the standards-compliant DOM way
612 :     var newPara = document.createElement("p");
613 :    
614 :     var textNode = document.createTextNode("\u2022 ");
615 :     newPara.appendChild(textNode);
616 :    
617 :     var codeNode = document.createElement("code");
618 :     newPara.appendChild(codeNode);
619 :    
620 :     textNode = document.createTextNode("text/livescript");
621 :     codeNode.appendChild(textNode);
622 :    
623 :     var div = document.getElementById("invalidtypes");
624 :     div.appendChild(newPara);
625 :     } else {
626 :     // the old DHTML way
627 :     document.writeln("<p>&bull; <code>text/livescript<\/code> <i>(without the <abbr>DOM<\/abbr>)<\/i><\/p>");
628 :     }
629 :     // -->
630 :     </script>
631 :     <script type="text/vbscript"><!--
632 :    
633 :     option explicit
634 :     dim newPara, textNode, codeNode, div
635 :    
636 :     set newPara = document.createElement("p")
637 :     set textNode = document.createTextNode(ChrW(&H2022) + " ")
638 :     newPara.appendChild(textNode)
639 :    
640 :     set codeNode = document.createElement("code")
641 :     newPara.appendChild(codeNode)
642 :    
643 :     set textNode = document.createTextNode("text/vbscript")
644 :     codeNode.appendChild(textNode)
645 :    
646 :     set div = document.getElementById("invalidtypes")
647 :     div.appendChild(newPara)
648 :     ' -->
649 :     </script>
650 :     <script type="text/vbs"><!--
651 :    
652 :     option explicit
653 :     dim newPara, textNode, codeNode, div
654 :    
655 :     set newPara = document.createElement("p")
656 :     set textNode = document.createTextNode(ChrW(&H2022) + " ")
657 :     newPara.appendChild(textNode)
658 :    
659 :     set codeNode = document.createElement("code")
660 :     newPara.appendChild(codeNode)
661 :    
662 :     set textNode = document.createTextNode("text/vbs")
663 :     codeNode.appendChild(textNode)
664 :    
665 :     set div = document.getElementById("invalidtypes")
666 :     div.appendChild(newPara)
667 :     ' -->
668 :     </script>
669 :    
670 :     <script type="text/tcl"><!--
671 :     # I know of no Web browsers that run Tcl.<br>
672 :     # The standard mentions text/tcl as an example value<br>
673 :     # for the Content-Script-Type header.<br>
674 :     document write "<p>&bull; <code>text/tcl<\/code><\/p>"
675 :     # -->
676 :     </script>
677 :     </div>
678 :     </div>
679 :     <p class="note bugzilla">Related <em class="browser">Mozilla</em> bug reports: <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=text-ecmascript">text-ecmascript</a>.</p>
680 :     </div>
681 :     </div>
682 :    
683 :     <div class="section" id="defer">
684 :     <h2>Deferring execution</h2>
685 :    
686 :     <div class="bodytext">
687 :     <p>The <a class="specsect" href="http://www.w3.org/TR/html4/interact/scripts.html#adef-defer" title="HTML 4.0 Specification: 18 Scripts"><code class="attribute">defer</code></a> attribute marks scripts that may be executed after the rest of a page has finished rendering. It is used for scripts that do not generate document content (using methods like <code>document.writeln()</code> functions in the scripts above).</p>
688 :    
689 :     <p class="note">Deferring <code>document.writeln()</code> functions until a page is fully loaded would cause generated content to be appended to the end of the page. However, one could defer a script that used <a href="glossary#dom" rel="glossary"><abbr title="Document Object Model">DOM</abbr></a> methods to insert content within a particular element in a document.</p>
690 :     </div>
691 :    
692 :     <div class="illo">
693 :     <h3>Example:</h3>
694 :    
695 :     <div class="blockcode">
696 :     <em class="html">&lt;script <em class="html4">type="text/javascript"</em>></em>&lt;!--<br>
697 :     <div class="indent">
698 :     var defer_support = "used";<br>
699 :     // --><br>
700 :     </div>
701 :     <em class="html">&lt;/script></em><br>
702 :     <em class="html">&lt;script <em class="html4">type="text/javascript"</em> <strong class="tested">defer</strong>></em>&lt;!--<br>
703 :     <div class="indent">
704 :     // may be executed after the following script<br>
705 :     var defer_support = "ignored";<br>
706 :     // --><br>
707 :     </div>
708 :     <em class="html">&lt;/script></em><br>
709 :     <em class="html">&lt;script <em class="html4">type="text/javascript"</em>></em>&lt;!--<br>
710 :     <div class="indent">
711 :     document.writeln("&lt;p>The &lt;code>defer&lt;\/code> attribute was ", defer_support, ".&lt;\/p>");<br>
712 :     // --><br>
713 :     </div>
714 :     <em class="html">&lt;/script></em><br>
715 :     </div>
716 :    
717 :     <h4 class="resultheader">Your Web browser renders it like this:</h4>
718 :     <div class="results" id="result3">
719 :     <script type="text/javascript"><!--
720 :     var defer_support = "used";
721 :     // -->
722 :     </script>
723 :     <script type="text/javascript" defer><!--
724 :     // may be executed after the following script
725 :     defer_support = "ignored";
726 :     // -->
727 :     </script>
728 :     <script type="text/javascript"><!--
729 :     document.writeln("<p>The <code>defer<\/code> attribute was ", defer_support, ".<\/p>");
730 :     // -->
731 :     </script>
732 :     </div>
733 :    
734 :     <p class="note bugzilla">Related <em class="browser">Mozilla</em> bug reports: <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=Defer">Defer</a>.</p>
735 :     <p class="note msie">Related <em class="browser">Internet Explorer</em> bug reports: <a href="http://channel9.msdn.com/wiki/default.aspx/Channel9.InternetExplorerStandardsSupport">Channel9 Wiki: Internet Explorer Standards Support</a>.</p>
736 :     </div>
737 :     </div>
738 :    
739 :     <div id="browserver">
740 :     <h2>Your Browser</h2>
741 :    
742 :     <p>Your Web browser identified itself as <strong><code id="useragent">Wget/1.11.4</code></strong> when it requested this page.</p>
743 :    
744 :     <script type="text/javascript" src="browserid.js"></script>
745 :     <noscript><p>Your Web browser did not run a script to reveal how it identifies itself to scripts.</p></noscript>
746 :     </div>
747 :    
748 :     <div id="footer">
749 :     <div id="buttons">
750 :     <a href="http://www.mozilla.com/firefox/" title="Mozilla Firefox"><object type="image/png" width="80" height="15" id="firefox_button" data="/images/buttons/firefox.png">Get Firefox</object></a>
751 :     <a href="http://my.opera.com/rlionheart/affiliate/" title="Opera"><object type="image/png" width="80" height="15" id="opera_button" data="/images/buttons/opera.png">Get Opera</object></a>
752 :     <a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/" title="Creative Commons Deed"><object type="image/png" width="80" height="15" id="cc_button" data="/images/buttons/cc.png">Some rights reserved.</object></a>
753 :     <a href="http://www.htmlhelp.com/cgi-bin/validate.cgi?url=referer" title="WDG HTML Validation Service"><object type="image/png" width="80" height="15" id="html401_button" data="/images/buttons/html401.png">Valid HTML 4.01</object></a>
754 :     <a href="http://jigsaw.w3.org/css-validator/check/referer" title="W3C CSS Validation Service"><object type="image/png" width="80" height="15" id="css_button" data="/images/buttons/css.png">Valid CSS</object></a>
755 :     </div>
756 :     <p><a rel="copyright" href="/copyright" class="local">&copy;</a> 1998 <span class="vcard"><a rel="home" href="/" class="local fn">Robin Lionheart</a> (<a rev="made" href="mailto&#58;lionheart&#64;robinlionheart&#46;com" class="email local">lionheart&#64;robin&shy;lionheart&#46;com</a>) [<a href="/robin/pubkey" class="local">public key</a>]</span></p>
757 :     <div id="dehanced">
758 :     <p>Best read with a browser that supports <abbr title="Extensible Hypertext Markup Language">XHTML</abbr>, <abbr title="Cascading Style Sheets level 2">CSS 2</abbr>, and <abbr title="Portable Network Graphics">PNG</abbr> images. I recommend <a href="http://www.mozilla.org/products/firefox/">Firefox</a>.</p>
759 :     <p>Degraded to fit your browser (JavaScript MIME type).</p>
760 :     </div> </div>
761 :    
762 :    
763 :    

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0