JAVASCRIPT HELLO WORLD PROGRAM - 2022

JAVASCRIPT HELLO WORLD PROGRAM


Let us take a sample example to print out "Hello World". We added an optional
HTML comment that surrounds our JavaScript code. This is to save our code
from a browser that does not support JavaScript. The comment ends with a "//--
>". Here "//" signifies a comment in JavaScript, so we add that to prevent a
browser from reading the end of the HTML comment as a piece of JavaScript
code. Next, we call a function document.write which writes a string into our
HTML document.

This function can be used to write text, HTML, or both. Take a look at the
following code.


<html>
  <body>
    <script language="javascript" type="text/javascript">
      <!--
document.write ("hello world")
//-->
      </script>
  </body>
</html>

No comments:

About Me

Powered by Blogger.