Reputation: 4108
I have one html file that calls external js file. I am presume html file does not reconize
external js file Since firebug throws error of 'myfunction() is not defined'.
Here is my code in external js file.
function a(){
//just function
}
and here is html file that makes trouble.
<script type="javascript/text" src="./myjs.js"></script>
<script>
a();
</script>
can anybody tell me why I can't implement this simplest js file? when I run html file on
python simpleHTTPServer, it even does not threw 404 error.
I am not sure what am I doing wrong here.
Upvotes: 0
Views: 175
Reputation: 4108
I could not load the function from js file because the function itself has an error.
Upvotes: 0
Reputation: 40448
It works for me. There must be something wrong with your path or your JS-File!
Upvotes: 0
Reputation: 4224
The problem could be that my.js is not loaded when you accessed the function. Try using the function in Firebug or something.
Upvotes: 0
Reputation: 943560
The (old) MIME type for JavaScript was text/javascript
, not javascript/text
.
The browser will consider javascript/text
to be an unknown scripting language and not execute it.
You appear to be using HTML 5 (since you are omitting the type
attribute on the second script element). Omit it on all your script elements.
Upvotes: 3
Reputation: 665
Check with firebug or chrome debugger if your js file path is correct and if it's correctly loaded.
You can see that in the "network" tab.
Upvotes: 0