JavaScript Tutorial - 6 - answer to Task 17
<html> <head> <title>Today</title> <script> function changeBackground() { var n=document.bgColor if (n=="#ffffcc") { document.bgColor="#ccffcc" } if (n=="#ccffcc") { document.bgColor="#ffffcc" } } </script> </head> <body bgcolor=#ffffcc> <form> <input type=button value="change colour" onClick=changeBackground()> </form> </body> </html> Note that the function definition goes in the header section.

HOME Table of Contents