Friday, March 4, 2011

Y10 Programming Lesson 2

Here's the code for PROMPTING (ASKING) what colour they want the page:
The Grey Code is ignored by the browser because of the /*...*/

<html>
<head>
<title>This is the Title</title>
</head>
<body>
<center><b>Hello My name is Mr Wells</b></center>
<script>
/* var WhatTheyHaveTyped = prompt("Please add a new Title: ");
document.title = WhatTheyHaveTyped; */

var rednum = prompt("How much red do you want on this page? - max 255")
var grnnum = prompt("How much green do you want on this page? - max 255")
var blunum = prompt("How much blue do you want on this page? - max 255")

function colourthepage()
{
document.body.style.backgroundColor = 'rgb(' + rednum + ',' + grnnum + ',' + blunum + ')';
}

colourthepage();
</script>
</body>
</html>

No comments:

Post a Comment