Methods


Methods do certain things. For instance, it could be an alert or it could write a variable. They are used like this:
methodname()

Sometimes, a method will have attributes, for instance, an alert has the text attribute. To make an alert, use this code:
alert('This is an alert')

Don't worry about where to put the code. You can put any methods after an event handler (more on that later) or inside the script tag.

If you want do write a var, type this:
document.writeln=(varname)

To write ordinary text put the text inside quotes like this:
document.writeln=("text")

To put both together, type the text inside quotes, end the quotes and put a plus sign before the variable name. To put more text, add another plus before another text section inside quotes. Just like this:
document.writeln=("text" + varname + "more text")

Some methods, such as the blink method, have no attributes. A blink is a blink and that is it.
The next section is variables
Back Homepage JavaScript Basics Next