By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

JavaScript Write Method

Reference entry on the JavaScript Write Method

Created: 2013-06-28 00:49

The JavaScript write method, is used to write HTML content.

The write method is often used in JavaScript examples. But what people want, is usually to change the content of a specific element, rather then the whole page. To see how to do this, see JavaScript innerHTML Property

Example

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

  <head>
    <title>My first Website</title>
  </head>

  <body>
    <script type="text/javascript">
      document.write("<p>This is my first JavaScript!</p>");
    </script>
  </body>

</html>