Skip to main content

Browser Specific Objects in Client-Based Scripts

Manipulating Object Properties

All JavaScript objects have at least one property, and some of them have a lot more. What you do with these properties depends on the object, but you generally use them for the following tasks:

  • Gathering information about an object's current settings. With the Text object, for example, you can use the value property to get whatever string is currently in the text box.
  • Changing an object's current settings. For example, you can use the Window object's status property to display a message in the browser's status bar.
  • Changing an object's appearance. With the Document object, for example, you can use the bgColor property to change the background color of the page.
  • Referencing a Property

Whatever the task, you refer to a property by using the syntax in the following generic expression: object.property, where objectis the object that has the property and propertyis the name of the property you want to work with. The dot (.) in between is called the property access operator. For example, consider the following expression:

 
window.location
 

This refers to the Window object's location property, which holds the address of the document currently displayed in the browser window. (In conversation, you'd pronounce this expression as "window dot location.")

 
<script language="JavaScript" type="text/javascript">
<!--
alert(window.location)
//-->
</script>
 

Next: Changing the Value of a Property