Jump to content

Javascript Files (script Src="...


RobberBaron
 Share

Recommended Posts

Files with the extension .js are real JavaScript files, so if you typed 'alert("Hi!")' and ran the file it would give the error "Line 1: Expression Expected". So when we link it with HTML (<script src="file.js">) does it really make a difference with the file type? I was making my own version of ASP written with JavaScript, and it would be useful to do <script src="file.asp">. So is this possible?

Link to comment
Share on other sites

The extension doesn't matter because you use the type attribute to tell the browser what kind of script it should be ready to parse:

<script type="text/javascript" src="file.ext"></script>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...