---
title: "Writing statements on browser using java script"  
description: "In this demonstration we learn that how to write output to a browser by using java script. We can use write () method of document object to write any"  
author: "Anonymous User"  
published: 2011-03-13  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/492/writing-statements-on-browser-using-java-script  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# Writing statements on browser using java script

In this demonstration we learn that how to write output to a browser by using java script. We can use write () method of document object to write any output to java script. Any statement that is written by java script is a command to the browser. Means to say if you have written document. write (“<p>Hello World</p>”) then it will create an html paragraph element. Following example demonstrate how to use document. write () method in java script.\

##### Example demonstrating use of document.write() in java script

```
<script type="text/javascript">        function displayStatements() {            document.write("<h2>This is a sample application which demonstrate use of document.write() method in java script</h2><br />");            document.write("Creating order list.<br /><font face='times new roman' size='5' color='green'>");            document.write("<ol type='i'>");            document.write("<li>Hello world.");            document.write("<li>It is a fantastic show.");            document.write("<li>By....");        }</script>
```

At the load event of the body or click event of any button call java script function displayStatements () and get required output.

##### Output of the above code is as follows

![Writing statements on browser using java script](https://www.mindstick.com/mindstickarticle/68789be4-02c0-479f-bcb2-2c33e1b4c156/images/61fd95e9-39ec-4aed-916b-32f1f9dd72a0.png)

---

Original Source: https://www.mindstick.com/articles/492/writing-statements-on-browser-using-java-script

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
