Navigate Site

Wednesday, December 29, 2010

Implementing Javascript from Scratch

techblog

# To insert a JavaScript into an HTML page, we use <script> tag.
     # Inside the <script> tag we use the type attribute to define the scripting language.
     # So, the <script type="text/javascript"> and </script> tells where the JavaScript starts and ends.

<html><body><script type="text/javascript">...</script></body></html>
     # The document.write command is a standard JavaScript command for writing output to a page.
<html><body><script type="text/javascript">document.write("Hello World!");</script></body></html>
     # In Majority of the cases <script> Tag is embedded within <head> section. For Ex:
<html><head><script type="text/javascript">function message(){alert("Test Message");}</script></head><body onload="message()"></body></html>
     # To optimize the application one can also use javascript in an external .js file. But The external script cannot contain the <script></script> tags. For Ex:
<html><head><script type="text/javascript" src="Extfile.js"></script></head><body></body></html>

 

For more details on Javascript visit Techblog

 

No comments:

Post a Comment