Introduction

Mostly, JavaScript runs in your web browser along side HTML and CSS, and can added to any web page using a script tag. The script element can either contain JavaScript directly (internal) or link to an external resource via a src attribute (external).

Internal :

You can just put the JavaScript inside a script element:
<script>
    alert("Hello, world.");
</script>

External
 :An external JavaScript resource is a text file with a .js extension, just like an external CSS resource with a .css extension.

To add a JavaScript file to your page, you just need to use a script tag with a src attribute pointing to the file. So, if your file was called script.js and sat in the same directory as your HTML file, your script element would look like this:

<script src="script.js"></script>

No comments:

Post a Comment