I'm trying to create an external .js file and it just doesn't seem to work.
I found an old example while searching the forum and tried to use it, but I can't seem to get it to call the file.
Here's the example:
myFile.js:
/* begin of js file */
// NOTE there are NOT <script> tags included
function foo() {
alert("foo");
}
/* end of js file */
myPage.html:
CODE
<script type="text/javascript" src="myFile.js"></script>
<!-- now call a function from it: -->
<script type="text/javascript">foo();</script>
NOt sure why I can't get it to work. what am I missing?
In addition, I actually want to the the external .js from within a script within a function...
Thanks,
Rich
I found an old example while searching the forum and tried to use it, but I can't seem to get it to call the file.
Here's the example:
myFile.js:
/* begin of js file */
// NOTE there are NOT <script> tags included
function foo() {
alert("foo");
}
/* end of js file */
myPage.html:
CODE
<script type="text/javascript" src="myFile.js"></script>
<!-- now call a function from it: -->
<script type="text/javascript">foo();</script>
NOt sure why I can't get it to work. what am I missing?
In addition, I actually want to the the external .js from within a script within a function...
Thanks,
Rich