How to show output in JAVA-SCRIPT Hello World

Show output in JAVA-SCRIPT Through writeln


For Javascript you need three hello worlds because there are three ways to communicate with the user, each increasingly more useful than the last.  The first method is to use the document.writeln(string) command. This can be used while the page is being constructed. After the page has finished loading a new document.writeln(string) command will delete the page in most browsers, so use this only while the page is loading. Here's how a simple web-page will look... 

<html>  
<head>
<title>Hellow World in Javascript</title>
 </head>
  <body>
    <script type='text/javascript'>
        document.writeln('Hello World!'); 
         </script> 
 </body>
 </html> 


How this Code Work!

 document.writeln('Hello World!');  will display the coated string 'Hello World!' on the screen.

As the page is loading, Javascript will encounter this script and it will output "Hello World!" exactly where the script block appears on the page. The problem with writeln is that if you use this method after the page has loaded the browser will destroy the page and start constructing a new one. For the most part, document.writeln is useful only when teaching yourself the language. Dynamic content during page load is better served by the server-side scripting languages. 

How to show Data in alert Box Click Here.