bookmark - Javascript Tutorial For Beginner Using Javascript in HTML page

Javascript Tutorial For Beginner - Using Javascript in HTML page

 
 Discussion by BDIT with 0 Replies.
 Last Update: May 2, 2008, 5:50 pm
 
bookmark - Javascript Tutorial For Beginner Using Javascript in HTML page  
    
free web hosting
 
In this tutorial I will show you how you can put JavaScript in a HTML page. It is very easy to add JavaScript in a HTML page. We will use <script> tag for this purpose. Inside the <script> tag, we will use "type=" attribute and will define the scripting language. We will define the script language as “text/javascript”. After define the script language we will add our JavaScript codes and at last we will close the tag using </script>. So the complete code will be-

CODE

<html>
<body>
<script type="text/javascript">

(Place for our JavaScript codes)

</script>
</body>
</html>


Now we will use “document.write” command (it is a standard command for JavaScript) to complete our previous code. This “document.write” command is a standard JavaScript command that writ output to a page. If we put “document.write("This is a JavaScript tutorial.");” inside the <script> tag, we will get output “This is a JavaScript tutorial.”. So the complete code is-

CODE

<html>
<body>
<script type="text/javascript">
document.write("This is a JavaScript tutorial.");
</script>
</body>
</html>


In previous example we used JavaScript in the body section. We can also use JavaScript in the head section. The system is similar, just put the script in the head section.

CODE

<html>
<head>
<script type="text/javascript">

(Place for our JavaScript codes here)

</script>
</head>
</html>


We can also use JavaScript in both head and body section.

CODE

<html>
<head>
<script type="text/javascript">
(Place for our JavaScript codes here)
</script>
</head>
<body>
<script type="text/javascript">
(Place for our JavaScript codes)
</script>
</body>
</html>


Remember that we can use unlimited number of scripts in your document. But every time we must use “<script>” tag before starting JavaScript and “</script>” tag in the end.

CODE

<html>
<head>
<script type="text/javascript">
(Place for our JavaScript codes here)
</script>
</head>
<body>
<script type="text/javascript">
(Place for our JavaScript codes)
</script>
<script type="text/javascript">
(Place for our JavaScript codes)
</script>
<script type="text/javascript">
(Place for our JavaScript codes)
</script>
</body>
</html>


I hope this little tutorial will help the beginner of JavaScript.

Fri May 2, 2008    Reply    New Discussion   


Quickly Post to Javascript Tutorial For Beginner Using Javascript in HTML page w/o signup Share Info about Javascript Tutorial For Beginner Using Javascript in HTML page using Facebook, Twitter etc. email your friend about Javascript Tutorial For Beginner Using Javascript in HTML page Print
Reply / Comment Ask a Question? Share / Bookmark E-Mail a Friend Print

Y = New Array()   Y = New Array() (2) (0) Javascript Operators   Javascript Operators