Simple JavaScript Example in Browser

In this topic, you will learn how to embed simple JavaScript in a Web page.

Create a file “abc.html” with below contents.










Executing the JavaScript code in HTML file

Now to execute the JavaScript file, all you need to do is open the HTML file in browser. Note that your JavaScript code should go inside <script> tag.

You should see the alert saying “hi”.


You may also like...