SQL PHP HTML ASP JavaScript articles and free scripts to download
 

document.write

We can use document object to send output to the client browser from our JavaScript code block. This is a simple way to send output and we can print any text we want to write. We can print the output within our JavaScript code block only.

document.write(“Hello World”);

The above command will print Hello World in the web browser. We can print variables like this.

my_var=”Hello World”
document.write(my_var)

We can print two variables like this

my_var="Hello World"
my_var1="Hello World"
document.write(my_var + my_var1)

To add a line break between two variables we can write like this. We can add line break before this by using document.writeln but it does not work properly so it is better to add a line break like above example where ever required.

document.write(my_var + "<br>"+my_var1 )

We can add line break before this by using document.writeln but it does not work properly so it is better to add a line break like above example where ever required.


Further readings
referrer: Getting the referrer of the browser to know how the visitor has arrived
title: Managing the title of the page
url: Collecting the full script path or URL by document object
lastModified: Last Modified date & time of the file or page
domain: domain name of the URL or site using this script
write: sening output text to browser by using document.write


Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked


Join Our Email List
Email:  
For Email Newsletters you can trust
Document Object