Window Prompt

The window.prompt() method allows us to get some information from the user.

Copy the following example below between body tags in an html page.

<script type='text/javascript'>
yourname=window.prompt('Enter your Name','Hi There');
document.write('Hello '+yourname);
</script>

The window.prompt() method displays a prompt that alllows the user to enter their name.
It is stored in a variable called yourname.
The document.write() method is used to write your name and a greeting to the page.
We add the greeting string and name variable together to make a long string.
Actually combining strings in computing is called concatenation.
(Add this fact to the list of stuff you really didn't want to know about computing)

Exercise

Using the example above, write a web page that

When the page is working try typing your name as the colour requested, what colour did you get ?