I'm sorry for this very newbish question, I'm not much given into web development. I've got this cool JavaScript in a .js file that we want to use on a small web site. (It's a script to run Cooliris on it).
How do use the .js file or attach it to my HTML code?
To execute JavaScript in a browser you have two options — either put it inside a script element anywhere inside an HTML document, or put it inside an external JavaScript file (with a . js extension) and then reference that file inside the HTML document using an empty script element with a src attribute.
To include an external JavaScript file, we can use the script tag with the attribute src . You've already used the src attribute when using images. The value for the src attribute should be the path to your JavaScript file. This script tag should be included between the <head> tags in your HTML document.
Open Notepad or TextEdit, open the template folder, then drag the . js file into Notepad or TextEdit and drop it. Open Notepad or TextEdit, select "file" then "open", browse to the template folder, select "all file types" and open the . js file that way.
Just include this line anywhere in your HTML page:
<script type="text/javascript" src="yourfile.js"></script>
Don't forget the closing tag as IE won't recongize it without a separate closing tag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With