faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 2 people (50%) answered Yes
Recently 1 of 2 people (50%) answered Yes


ok when i use an if statement with a confirm box and the user clicks cancel how do i not open page?

Aug 24th, 2008 15:30
Abolfazl Shirazi, Lisa Lambert,

Abolfazl Shirazi:
your question is not clear. whatever......
you can control any confirmbox easily. page below is an example of 
controling "Ok" button pressing or "Cancel" button pressing.
<script language="javascript" type="text/javascript">
function ConfirmBox() {
	if (confirm("ComfirmBox Example. Please click Ok or Cancel.")) 
		alert("You pressed Ok button.")
		/*Any function for pressing Ok here*/
		return true
	else {
		alert("You pressed Cancel button.")
		/*Any function for pressing Cancel here*/
		return false
<button onclick="ConfirmBox()">Click here</button>
if you don't get your answer, explain your question more clearer
Have Fun