How to Include Javascript to HTML Page with inline script

Description

To include inline JavaScript code, place JavaScript code inside the script element directly, as follows:


<script type="text/javascript">
function sayHi(){
    alert("Hi!");
}
</script>

Note

The JavaScript code contained inside a script element is interpreted from top to bottom.

As with inline JavaScript code, processing of the page is halted while the external file is interpreted.

A script element with the src attribute should not include additional JavaScript code between the <script> and </script> tags.

If both are provided, the script file is downloaded and executed while the inline code is ignored.





















Home »
  Javascript »
    Javascript Introduction »




Script Element
Syntax
Data Type
Operator
Statement
Array
Primitive Wrapper Types
Function
Object-Oriented
Date
DOM
JSON
Regular Expressions