Forum Moderators: open

Message Too Old, No Replies

Including .js file?

Is it like C++?

         

Emperor

3:56 pm on Oct 8, 2004 (gmt 0)

10+ Year Member



Hi guys,

I made a file called functions.js which is, you guessed it, JavaScript functions.

Is this how I add it (it works fine):

<head>
<script type="text/javascript" src="functions.js"></script>
</head>

I should use the "type=..." right? Should I put anything else in there? I just want to make sure.

Emperor

StupidScript

5:10 pm on Oct 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep. Include the type="text/javascript" attribute and you're in compliance.

BTW, you can use pretty much any text file extension for your scripts, not just .JS. You are telling the browser what MIME type to use with your SCRIPT reference, so it will chew up .JS, .TXT, .HTML, .SCRIPT, .WHATEVER ...

<script type="text/javascript" language="javascript" src="myscript.xyz"></script>

As long as "myscript.xyz" is Javascript, you're set.

(I mention this as a teeny security note, in case you want an extra layer between the obvious file types and potential abuse.)