Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a .js file?

Tags:

javascript

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?

like image 894
fmsf Avatar asked Oct 14 '08 08:10

fmsf


People also ask

How do you run a .JS file?

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.

HOW include JS file in HTML?

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.

How do I open a .JS file in Windows 10?

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.


1 Answers

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.

like image 105
Tamas Czinege Avatar answered Sep 17 '22 15:09

Tamas Czinege