1.5 About Internet Explorer
1.6 Your first script
The HTML code shouldn't be any problem, but the code between the <script> tags will be explained soon.
1.7 The <script> tags
Now we now all this, we should add those two little lines to our first script code.
1.9 Where to put Scripts?
The document.write() method is one that you will be using a lot. For now, don't worry too much about what a method is, we will explain that and why you see the period between the words document and write later in this tutorial. The syntax for the document.write() method is as follows:
A string is nothing more than a series of characters. You put the characters in quote marks, except when the string is something that is returned by another method (like Date), which was the case in our first script, or is a variable which you will learn about later in this tutorial.
So if you wanted to write "Welcome to my personal web page" using document.write(), this is how you should do it:
document.write("Welcome to my personal web page")
You can include HTML tags in this string if you want. This way you can underline your welcome by doing the following. I will add a second and a third line too.
document.write("<u>Welcome to my Web Page</u>")
document.write("<br>Have a nice stay!")
document.write("<br>Hope you will be back soon!")
Now suppose you want to use document.write() to insert an image in the document. Normally we would use the <img> tag to do this. The tag would look something like this if you were inserting a picture of Saturn named saturn.jpg.
1.11 What you need to know to move on to the next lesson.
- Know how to hide your scripts from older browsers.
- Know that you can use the document.write() method to write to the document as it is loading.