Make your own free website on Tripod.com

Javascript Tutorial Part 1

myitcareer.org-Your IT Career Partner For Life. Please Bookmark It.
Homework Help | Buy Book | Buy Phone | Top Web Hosts | Hire Web Designer
Home | Interview Questions And Answers | Plan Wedding | Online Tuition
Top Domain Registrars | Hire Freelancer | Hosting Charges | Hindi News

How to put a JavaScript into an HTML document <html>
<head>
</head>
<body>
<script language="JavaScript">
document.write("Hello World!")
</script>
</body>
</html> And it produces this output: Hello World! To insert a script in an HTML document, use the <script> tag. Use the language attribute to define the
scripting language. <script language="JavaScript"> Then comes the JavaScript: In JavaScript the command for writing some text on a page is
document.write: document.write("Hello World!") The script ends: </script> How to handle older browsers Older browsers that do not support scripts will display the script as page content. To prevent them from
doing this, you can use the HTML comment tag: <script language="JavaScript">
<!--
some statements
//-->
</script> The two forward slashes on front of the end of comment line (//-->) are a JavaScript comment symbol, and
prevent the JavaScript from trying to compile the line. Note that you cannot put // in front of the first comment line (like //<!--), because older browser will display it.
Funny? Yes ! But that's the way it is. Where to put the JavaScript Scripts in a page will be executed immediately while the page loads into the browser. This is not always
what we want. Sometimes we want to execute a script when a page loads, other times when a user trigger
an event.
Next