Where and How to ?
The <script> Tag
<script> alert('Hello World'); </script>
Above example, will bring the pop-up box with message "Hello World".
Some people would recommend you to place your all "<script>" tag in your <head> tag, but speaking frankly that is actuall bad idea. To make your webpage load faster or more effectively. It is highly advised to keep your <script> tag right before </body> tag like beolow :-
We will talk about "onlick" and other event later on our tutorial.
Note: If any website or person, tells you to place your <script></script> tag inside <head></head> , Don't listen at all. He is an Idiot. It's better to run away from people like him.
script can also be placed in external file, which is again good idea only if you have lots of script code.
- make your page more clean and
- helps in faster development purpose.
- easier to read and maintain.
Example How to ?
Create a new file "scripts.js" like below :-
Now, in your HTML file, just place below syntax , right before </body> tag like below:
Remember : External scripts cannot contain <script> tags.
Related Results :
- Related Posts are generally User Blog posts.
- or Other tutorials from other networks of w3clan.com.
- Any registered user can create related posts based on search term tags.