JavaScipt Statements 2

In this Session we can view:

window.document.write(" ");
document.write(" ");
Java Script Statements

window.document.write(" ");  V/S   document.write(" ");

Initially there is no big difference between this two statements the window represents the web browser and the document represent the web page. So without browser their is no meaning of page. Think window is a class and document is an object. The window contain lot of object in that document is one of the objects.Here by default name is object. And the after "document" the "write" it is the method

For ex:
<!doctype html>
<body>
    <script type="text/javascript" language="javascript">
        window.document.writeln("JavaScript <br/>");
         document.writeln("LiveScript ");
    </script>
</body>

Output: 


To add space between two statement: 

1 You can add special character &nbsp; (non breaking space)
2 You can add writeln for space like document.writeln("Coding Atharva");

Note: When ln is there pre tag is perfectly supporting but when you removed ln it will displayed as it              is without space.

Without ln :

<!doctype html>
<body>
    <pre>
<script type="text/javascript" language="javascript">
     document.write("JavaScript");
     document.write("Coding Atharva");
    </script>
    </pre>
</body>

Output: 


























With ln :

<!doctype html>
<body>
    <pre>
<script type="text/javascript" language="javascript">
     document.writeln("JavaScript");
     document.write("Coding Atharva");
    </script>
    </pre>
</body>


Output: 



Previous
Next Post »