Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Javascript Tutorial For Beginner, Using Javascript in HTML page
BDIT
post May 2 2008, 05:50 PM
Post #1


Newbie [ Level 2 ]
Group Icon

Group: [HOSTED]
Posts: 11
Joined: 30-April 08
Member No.: 30,066



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.



This post has been edited by BDIT: May 2 2008, 05:53 PM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. What You Need Before You Can Create A Text-based Game..(7)
  2. Converting PSD To HTML(9)
  3. Linux Beginners - Tutorial On Editors In Linux.(3)
  4. How To Increase Your Google Page Rating ?(12)
  5. Converting HTML over to XHTML(13)
  6. Center Update(5)
  7. How To Remove Bad Sectors Or Bad Clusters From HDD(16)
  8. Wireless: Bypassing Mac Filtering(10)
  9. A Solution For Disabled Right Click On Web Page(20)
  10. How To: Display A Members/user List.(3)
  11. Moving To Fedora 9(1)
  12. Joomla Template Kit Extension For Nvu/composer(2)
  13. VB.NET: MS-Access Interaction Tutorial (Part I)(18)
  14. Indentation In Html(4)
  15. Mp3 Questions(14)
  1. Hacked By Dumansal(2)
  2. Pre Loader Tutorial For Flash(6)
  3. Choosing A Different Joomla Start Page(5)
  4. Hidden A Page Url(1)
  5. Bulletproof Ftp Server Tutorial(0)
  6. Make It Impossible To View Page Source(11)
  7. Using The Php Mail() Function For Images Or Attachments(3)
  8. Web Editor(0)
  9. Installing Glut To Dev C++(3)
  10. Gimp Userbar Tutorial(3)
  11. Safety(9)
  12. 3ds Max Tutorial #2-creating Reflective Materials(1)
  13. How To Make An Test-based Rpg Game!(4)
  14. Photoshop Tutorial: Full Grunge Signature(16)
  15. PHP Tutorial: Form Verification And Simple Validation(12)


 



- Lo-Fi Version Time is now: 7th September 2008 - 07:10 PM