Changes

Jump to: navigation, search

JavaScript Document Object

844 bytes added, 20:39, 14 May 2007
Changing the Document Title
<form action="">
<input type=button value="Press to change title" onclick="document.title='hello'"/>
</form>
</body>
</html>
 
</pre>
 
=== Changing the Document Colors ===
 
A similar approach can be used to change the colors using in the document. As outlined in the document object properties table there a number of color setting raninging from foreground and background colrs through to colors used for links (such as visited and unvisted link colors). The following example changes the foreground and background colors when the "Change colors" button is pressed:
 
<pre>
 
<html>
<head>
<title>JavaScript Document Object Example</title>
<script language="javascript" type="text/javascript">
 
function changeColors()
{
document.fgColor="red";
document.bgColor="blue";
}
</script>
</head>
 
<body>
<p>
Sample text to show color change
</p>
<form action="">
<input type=button value="Change colors" onclick="changeColors()"/>
</form>
</body>

Navigation menu