Alert Boxes

See also CSS & Scripts Alert Box.

Pressing the button brings up an alert box containing your own message.

<button onclick="alert('Hello, I am an Alert Box')">Alert Button!</button>

To start a new line put \n or \r where your line break will be you can also use \t to apply a tab space

alert('Hello\nI am an Alert Box')
alert('Hello\tI am an Alert Box')
alert('Hello\n\tI am an Alert Box')

Confirm.

The Confirm Alert gives you the option to cancel.

Confirm Link

<a href="yourpage.htm" target="_blank" onclick="return confirm('Are you sure you want to load the test page?')">Confirm Link</a>

Example of a confirm box that will allow users to choose between going to two places:
The confirm method returns true if the user chooses OK and false if the user chooses Cancel.

<script type="text/javascript">
<!--
function whereTo(){
var isConfirmed=confirm('Choose "OK" for one, "CANCEL" for two')
if(isConfirmed){
location="yourpage1.html"
}
else{
location="yourpage2.html"
}
}
//-->
</script>

<button onclick="whereTo()">Choose to go</button>


A prompt allows you to take an input from a user and use it with a script.

<button onclick="var temp = window.prompt('This is the Prompt Text:','This is the Text Box value, Click ok then check the status bar');window.status=temp"> Display a Prompt</button>