Studying Writing Javascript in HTML

Studying Writing Javascript code in HTML


Javascript is a programming language that operates on the browser to be written in HTML code. There are four ways of writing javascript code in HTML.

First way: The
    







The result:
Studying Writing Javascript in HTML


Second way: Through External Files

If you do not want the Javascript code mixed with HTML, you can write it in a separate file. The trick, create a file with extension js javascript file extension, such as coding the following contents:
// file-external.js
alert ("This is the Output of an external Javascript file");



After storing the above code, we need to connect an external file with the HTML file. You do this by using the tag 
    




Not only is there a javascript onclick event on a wide range of other events, such as onsubmit, onload, ondoubleclick, onmouseover, onmouseout, and so on.

Fourth Way: Using the URL

For the last way that the writing Javascript in your URLs. This control is rarely used, but we also need to know to get to know javascript. Javascript writing the protocol URL by using Javascript. For example, try to write code like this in the browser URL.

javascript:alert("This output From Javascript")

The result will be executed output Javascript by the browser.

Then, How can we use this method in HTML?


Spread the love

Fajar (Ucup)

The owner and author of FajarYusuf.com and also someone who likes to share interesting information with others.

Leave a Reply

Your email address will not be published. Required fields are marked *