Using Object Properties and Methods in JavaScript

JavaScript programming centers on objects, to a large extent. We've already seen the document object and seen that one way to use that object is to use methods such as writeln to indicate that you want to write to a Web page. To use a method, you use the object's name, followed by a dot (.) and then the method name, such as document.writeln. Here are a few examples of methods:

  • document.write— Writes to the body of the current Web page

  • document.writeln— Writes to the body of the current Web page and ends the text with a carriage return

  • history.go— Makes the browser navigate to a particular location in the browser's history list

  • window.alert— Makes the browser display an alert dialog box

  • window.open ...

Get Real World XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.