JavaScript structure
The structure of JavaScript is as follows:
< SCRIPT LANGUAGE = "JavaScript" >
Writing javascript code
// - ->
< /SCRIPT>
Information :
Code
generally included with the aim that if the browser does not recognize JavaScript then the browser will treat it as a comment so is not displayed in the browser window.
JavaScript as an object-oriented language Property
Property is an attribute of an object. For example, car objects have car color properties.
Writing:
Name_object.property = value
window.defaultStatus = "Happy Learning JavaScript";
Method
The method is a collection of code used to do something action
against the object.
Writing:
Name_objek.name_method (parameter)
document.write ("Hallo")
The location of JavaScript in HTML
Javascript script in HTML document can be placed on:
- Head Section
- Body Parts (rarely used).
Here's a simple example of using javascript alerts in HTML pages, to make it please open a text editor like notepad then write the following code and save it with the name basic1.html< HTML>
< HEAD>
< TITLE> Alert Box < /TITLE>
HEAD>
< BODY>
< SCRIPT LANGUAGE = "JavaScript">
window.alert ("This is a message for you");
// ->
< /SCRIPT>
< /BODY>
< /HTML>
after that run using the browser you use.
just so much of our learning today :)