Skip to main content

Changing the Value of a Property

Some properties are "read-only," which means your code can only read the current value and can't change it. However, many properties are "read/write," which means you can also change their values. To change the value of a property, use the following generic syntax:

 
object.property = value
 

As before, object is the name of the object that has the property, and property is the name of the property you want to change. The value part is a literal value (such as a string or number) or an expression that returns the value to which you want to set the property.

Example : Changing the value of a property

 
<script language="JavaScript" type="text/javascript">
<!--
var new_address = prompt("Enter the address you want to surf to:")
window.location = new_address
//-->
</script>


 

Next: Example: Showing Properties