home > real world > web resource > web source codes >
This link will turn white on blue background: source.html
This link will turn yellow on red background: source.html
STEP 1/2: Put this code into the <HEAD> of your document:
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function doColor(item, color, bg) {
item.style.color = color; // changes text color
item.style.backgroundColor = bg; // changes background
}
function undoColor(item) {
item.style.color = "#9999ff"; // sets color back to blue
item.style.backgroundColor = ""; // sets background to default
}
// End -->
</script>
</HEAD>
STEP 2/2:Copy this code into the <BODY> of your HTML document:
<BODY>
<P>This link will turn white on blue background: <a name="link1" href="source.html" onmouseover="doColor(link1, 'white','#7788ff');" onmouseout="undoColor(link1);">source.html</a></P>
<P>This link will turn yellow on red background: <a name="link2" href="source.html" onmouseover="doColor(link2, 'yellow','red');" onmouseout="undoColor(link2);">source.html</a></P>
</BODY>
|