articles

Home / DeveloperSection / Articles / Writing statements on browser using java script

Writing statements on browser using java script

Anonymous User6607 13-Mar-2011

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


Updated 07-Sep-2019
I am a content writter !

Leave Comment

Comments

Liked By