
javascript confirm yes no - how to create confirm dialog box yes or no in JavaScript?

if (confirm('Are You Sure')){
window.location = "http://www.roseindia.net/";
}else{
alert("you are not redirected")
}

How to confirm yes or no in JavaScript
There is confirm Box popup in JavaScript that can be used to get confirmation from user. For example if you wants to open a webpage get it confirm first. There must be two options in confirm box "ok" and "cancel". or may be yes or no.
Syntax to write confirm: confirm("yourMesg");
See the code below..
<html>
<head>
<script type="text/javascript">
function show_confirm()
{
var con = confirm("Are You Sure");
if (con ==true)
 {
 alert("You pressed OK!");
 }
else
 {
 alert("You pressed Cancel!");
 }
}
</script>
</head>
<body>
<input type="button" onclick="show_confirm()" value="Show confirm box" />
</body>
</html>

showConfirm("Your message",<OnConfirmationCallingmethod>, 0, false);
Syntax: showConfirm("text",function, number/variable, boolean);