Let’s have a look at those document Methods. They were: open( ), close( ), write( ), writeln( ).
We’ve already done write( ), and writeln( ) is the same as write( ) except that you get a line break. So we’ll look (briefly) at open( ) and close( )
We’re not going to be using this method, but for reference purposes here’s what it does.
The default for document.write( ) is to write stuff in the current document window – the browser window. It doesn’t need to open a new window, because it already has one to work with. You can use document.open( ) to create a new document and send it things like HTML code. You could send the HTML code with document.write( )
This method is used to close the document you created with the open( ) method.
Two useful document Events you can use are these:
These are typically used in the BODY section of the HTML code. Here’s two pieces of code that will annoy visitors to your site:
<BODY onLoad = “alert(‘Welcome to my web page’)”>
Or when they leave your site, there’s this:
<BODY onUnoad = “alert(‘Goodbye – Have a nice day’)”>
We’ll see another way to annoy your visitors when we create a pop-up window. We’ll do that real soon. The next part will look at another object that is widely used – the navigator object.