PROGRAMMING SOLUTIONS

Sunday 2 August 2009

Yes/No message box in javascript

There are many times where we want ask or confirm about an action through a page, this can be achieved using the "confirm" javascript function. The "confirm" function returns 1 if the "OK" button was pressed and 0 for the "Cancel" button.

Example:

function msgboxYesNo() {
if (confirm("Are you sure you want to move to the next page?")) {
window.location.href = "nextpage.html";
}
}


Test it!

No comments:

Post a Comment