Microsoft KB Archive/172924: Difference between revisions

From BetaArchive Wiki
m (Text replacement - "<" to "<")
m (Text replacement - "&" to "&")
 
(2 intermediate revisions by the same user not shown)
Line 45: Line 45:
== SYMPTOMS ==
== SYMPTOMS ==


The SRC attribute of the <SCRIPT&gt; tag lets you specify a file as the JavaScript source, rather than embedding the JavaScript in the HTML. Here's an example:
The SRC attribute of the <SCRIPT> tag lets you specify a file as the JavaScript source, rather than embedding the JavaScript in the HTML. Here's an example:
<pre class="codesample"><HEAD&gt;
<pre class="codesample"><HEAD>
<TITLE&gt;My Page</TITLE&gt;
<TITLE>My Page</TITLE>
<SCRIPT SRC=&quot;common.js&quot;&gt;
<SCRIPT SRC="common.js">
...
...
</SCRIPT&gt;
</SCRIPT>
</HEAD&gt;
</HEAD>
<BODY&gt;
<BODY>
...
...
                 </pre>
                 </pre>
Line 62: Line 62:
== STATUS ==
== STATUS ==


Internet Explorer 4.x and 5 supports the SRC attribute of the <SCRIPT&gt; tag.
Internet Explorer 4.x and 5 supports the SRC attribute of the <SCRIPT> tag.


</div>
</div>
Line 72: Line 72:


<pre class="codesample"> =====HTML File=====
<pre class="codesample"> =====HTML File=====
<HTML&gt;
<HTML>
<HEAD&gt;
<HEAD>
<TITLE&gt;SRC Sample</TITLE&gt;
<TITLE>SRC Sample</TITLE>
</HEAD&gt;
</HEAD>
<BODY&gt;
<BODY>
<H3&gt; SRC Example </H3&gt;<HR&gt;
<H3> SRC Example </H3><HR>
<FORM&gt;
<FORM>
<SCRIPT LANGUAGE=&quot;Javascript&quot; SRC=&quot;script.js&quot;&gt;
<SCRIPT LANGUAGE="Javascript" SRC="script.js">
document.write(&quot;If you see this text, your browser does not support &quot; +
document.write("If you see this text, your browser does not support " +
               &quot;the SRC attribute of the &amp;ltSCRIPT&amp;gt tag.&quot;);
               "the SRC attribute of the &ltSCRIPT&gt tag.");
</SCRIPT&gt;
</SCRIPT>
</FORM&gt;
</FORM>
</BODY&gt;
</BODY>
</HTML&gt;
</HTML>


=====script.js=====
=====script.js=====
document.write(&quot;Hello from inside script.js&quot;);
document.write("Hello from inside script.js");


                 </pre>
                 </pre>
Line 95: Line 95:
NOTE: External JavaScript files cannot contain any HTML tags; they must contain only JavaScript statements and function definitions.<br />
NOTE: External JavaScript files cannot contain any HTML tags; they must contain only JavaScript statements and function definitions.<br />
<br />
<br />
External JavaScript files should have the file name suffix .js, and the server must map the .js suffix to the MIME type &quot;application/x-javascript,&quot; which the server sends back in the HTTP header. To map the suffix to the MIME type, add &quot;application/x-javascript,js,5&quot; to the server's Registry key HKEY_LOCAL_MACHINE/System/ControlSet001/Services/InetInfo/Parameter/MimeMap and then restart the server.<br />
External JavaScript files should have the file name suffix .js, and the server must map the .js suffix to the MIME type "application/x-javascript," which the server sends back in the HTTP header. To map the suffix to the MIME type, add "application/x-javascript,js,5" to the server's Registry key HKEY_LOCAL_MACHINE/System/ControlSet001/Services/InetInfo/Parameter/MimeMap and then restart the server.<br />
<br />
<br />
If the server does not map the .js filename suffix to &quot;application/x- javascript&quot; MIME type, the browser will not load the JavaScript file specified by the SRC attribute properly.
If the server does not map the .js filename suffix to "application/x- javascript" MIME type, the browser will not load the JavaScript file specified by the SRC attribute properly.


</div>
</div>

Latest revision as of 11:29, 21 July 2020

Article ID: 172924

Article Last Modified on 3/3/2005



APPLIES TO

  • Microsoft Internet Explorer 3.0
  • Microsoft Internet Explorer 3.01



This article was previously published under Q172924

SYMPTOMS

The SRC attribute of the <SCRIPT> tag lets you specify a file as the JavaScript source, rather than embedding the JavaScript in the HTML. Here's an example:

<HEAD>
<TITLE>My Page</TITLE>
<SCRIPT SRC="common.js">
...
</SCRIPT>
</HEAD>
<BODY>
...
                

This attribute is especially useful for sharing functions among many different pages. Unfortunately, Internet Explorer 3.x does not support it.

STATUS

Internet Explorer 4.x and 5 supports the SRC attribute of the <SCRIPT> tag.

MORE INFORMATION

Steps to Reproduce Behavior

 =====HTML File=====
<HTML>
<HEAD>
<TITLE>SRC Sample</TITLE>
</HEAD>
<BODY>
<H3> SRC Example </H3><HR>
<FORM>
<SCRIPT LANGUAGE="Javascript" SRC="script.js">
document.write("If you see this text, your browser does not support " +
               "the SRC attribute of the &ltSCRIPT&gt tag.");
</SCRIPT>
</FORM>
</BODY>
</HTML>

=====script.js=====
document.write("Hello from inside script.js");

                



NOTE: External JavaScript files cannot contain any HTML tags; they must contain only JavaScript statements and function definitions.

External JavaScript files should have the file name suffix .js, and the server must map the .js suffix to the MIME type "application/x-javascript," which the server sends back in the HTTP header. To map the suffix to the MIME type, add "application/x-javascript,js,5" to the server's Registry key HKEY_LOCAL_MACHINE/System/ControlSet001/Services/InetInfo/Parameter/MimeMap and then restart the server.

If the server does not map the .js filename suffix to "application/x- javascript" MIME type, the browser will not load the JavaScript file specified by the SRC attribute properly.

Keywords: kbprb kbcode KB172924