How to add javascript on web page

10 Apr 2014, 11:56 AM

There are several ways to add Javascript code in your web page, but there are two most common ways used by the developer to add script in the page.

1. If code is short then place it inside the same page using the <script> tag. You can add <script> tag anywhere in the page but it’s better to add it within the <head> tag.

    <title>Java script test page</title>

    <script type="text/javascript">
        alert("Hello World!");


2. If the script code is very large then you can also make a separate JavaScript file and include its path in the web page.

    <title>Page Title</title>
    <script type="text/javascript" src="myjavascript.js"></script>

Related Contents

15 May 2014, 08:07 AM
C#, LINQ, List
15 May 2014, 07:54 AM
C#, LINQ, List
29 Apr 2014, 03:07 AM
C#, Generic
Explains How to add javascript on web page

Date Posted 10 Apr 2014, 11:25 AM
Author Brainy Solutions
Views 2,134