JavaScript - Variables and Document.write

Insert the below into the <head> section of your page


Insert the below into the <body> section of your page



Description

Using the above JavaScript you can specify text to be used throughout your page by just writing it once then have it re-wrote on your page using document.write and specifying the variable(s) to be used.  See example highlighted in yellow above.

Variables

A variable can be defined as a number or a piece of text, and you can use the variable value throughout your script. You just need to declare the variable's name and value. Note:- Variable names in JavaScript are case sensitive and They must begin with a letter or the underscore character _

document.write()

Download

Download the example code from above or Click Here too see it in a new window.

Rate this Tutorial

Like this page?

If you find this page useful, please consider linking to it. Simply copy and paste the code below to your website, blog, or profile
or Click here to exchange Links.



Protected by Copyscape Original Content Check