Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

JavaScript confirm code


<head>

<script language="javascript">

function getConfirmation(){

var yes //Define the local variable yes /*
Show the dialog with the confirm method and pass it the string as it's value
*/
yes = confirm('Are you sure you want to change the background color?')
if(yes){//Test if the returned value from the dialog is "true"
/*
Change the background color of the document to blue
*/
document.bgColor = "blue"
}
}
</script>
</head>

<body bgcolor="#FFFFFF">

<form>
<!--
Define the button
and make the onClick event of it call the getConfirmation function
-->
<input type="button"
value="Set background color to blue"
onClick="getConfirmation()">
</form>
</body>


Close