JavaScript Program to Change background color of web page at runtime

Write a JavaScript program to accept color name from user and set it to change background color of webpage.



Source Code
<html>
<head>
    <title>Background color change</title>
    <script>
        function changeColor()
        {
            var color = prompt('Enter a color please', '')
            document.body.style.backgroundColor = color
        }
    </script>
</head>
<body onload="changeColor()">
<p>Refresh page to change background color</p>
</body>
</html>
Output