Writing normal text with JavaScript.
Normally every one likes to show their content via HTML web pages with HTML tags. But here i like to write text content inside JavaScript with document object and write property.
<html>
<body>
<script type="text/javascript">
document.write("This an example for writing normal text using JavaScript");
</script>
Output
Alert Message on document load
<html>
<head>
<script type="text/javascript">
function message()
{
alert("Welcome");
}
</script>
</head>
<body onload="message()">
</body>
</html>
The above example program explains how a function in the header is called and alert message is given. Every function can be called when ever an event or action is performed.
Writing HTML tags inside JavaScript
<html>
<head>
</head>
<body>
<script type="text/javascript">
document.write("Welcome");
</script>
</body>
</html>
Insert HTML tags in document.write("<b>Welcome</b>");
The above example explains how easily you can use HTML tags inside a JavaScript using document object and write property.