JavaScript Basics : (INTRODUCTION)
Javascript is a scripting language that will allow you to add real programming to your webpages.
You can create small application type processes with javascript, like a calculator or a primitive game of some sort.
However, there are more serious uses for javascript:
This tutorial covers all the core things you need to know before you can build and customize your own cool scripts.
Since javascript isn't HTML, you will need to let the browser know in advance when you enter javascript to an HTML page. This is done using the <script> tag.
The browser will use the <script> type="text/javascript"> and </script> to tell where javascript starts and ends.
Consider this example:
<html>
<head>
<title>My Javascript Page</title>
</head>
<body>
<script type="text/javascript">
alert("Welcome to my world!!!");
</script>
</body>
</html>
The word alert is a standard javascript command that will cause an alert box to pop up on the screen. The visitor will need to click the "OK" button in the alert box to proceed.
By entering the alert command between the
<script type="text/javascript"> and </script> tags, the browser will recognize it as a javascript command.
If we had not entered the <script> tags, the browser would simply recognize it as pure text, and just write it on the screen.
You can enter javascript in both the <head> and <body> sections of the document.
In general however, it is advisable to keep as much as possible in the <head> section.
You can create small application type processes with javascript, like a calculator or a primitive game of some sort.
However, there are more serious uses for javascript:
- Browser Detection
Detecting the browser used by a visitor at your page. Depending on the browser, another page specifically designed for that browser can then be loaded. - Cookies
Storing information on the visitor's computer, then retrieving this information automatically next time the user visits your page. This technique is called "cookies". - Control Browsers
Opening pages in customized windows, where you specify if the browser's buttons, menu line, status line or whatever should be present. - Validate Forms
Validating inputs to fields before submitting a form.
An example would be validating the entered email address to see if it has an @ in it, since if not, it's not a valid address.
This tutorial covers all the core things you need to know before you can build and customize your own cool scripts.
Since javascript isn't HTML, you will need to let the browser know in advance when you enter javascript to an HTML page. This is done using the <script> tag.
The browser will use the <script> type="text/javascript"> and </script> to tell where javascript starts and ends.
Consider this example:
<html>
<head>
<title>My Javascript Page</title>
</head>
<body>
<script type="text/javascript">
alert("Welcome to my world!!!");
</script>
</body>
</html>
The word alert is a standard javascript command that will cause an alert box to pop up on the screen. The visitor will need to click the "OK" button in the alert box to proceed.
By entering the alert command between the
<script type="text/javascript"> and </script> tags, the browser will recognize it as a javascript command.
If we had not entered the <script> tags, the browser would simply recognize it as pure text, and just write it on the screen.
You can enter javascript in both the <head> and <body> sections of the document.
In general however, it is advisable to keep as much as possible in the <head> section.
কোন মন্তব্য নেই