Web Teacher Software
web database
Javacript 
Tutorial
CGI tutorial
web 
database consulting
web database training
contact us about web 
database software
press
Hosted Database Solutions
webteacher home
Web Teacher Consulting

javascript tutorial graphic


Webteacher Software now offers

Writing to a document

You can create an HTML document 'on the fly' with JavaScript using the document.write() method. Normally, you must open a new document first. Then you may write to that document, and finally you must close the document so that the Browser can stop tryi ng to load it. Here is an example:

document.open()
document.write("Hello There")
document.close()

When I create a new window, I am also opening a new document. So I can write to a new window with this series of commands.

NewWindow = window.open("","","width=200,height=200")
NewWindow.document.write("Hello There")
NewWindow.document.close()

The document.write() method can contain either text or a variable inside the perentheses. The following example creates a variable, then writes the variable to a new document.

SampleText = "Hello there, " +
"It's nice to see you again."

NewWindow = window.open("","","width=200,height=200")
NewWindow.document.write(SampleText)
NewWindow.document.close()

I can even include HTML tags in the document.write() statement. Like this:

NewWindow = window.open("","","width=200,height=200")
NewWindow.document.write("<CENTER><H1>Hello there</H1></CENTER>")
NewWindow.document.close()

More about document.write()

Home | WebData - Web Database Software | Javascript | CGI | Consulting | Map Builder | Contact Us | The Press Room