We are going to enhance our background colour script by first turning our inline script into an internal script.
Here we call a function to change the background colour by clicking on a link.
<head> <script type='text/javascript'> function changecolour() { document.body.style.backgroundColor='blue';} </script> </head> <body> <a href="javascript:void(0);" onclick='changecolour();'>Make Me Blue</a> </body>
Exercise
Create a web page with this code on it.
Now use a parameter in the changecolour() function to allow the user to choose from several different background colors.