Welcome to another JavaScript tutorial of mine..This will code will determine if the user pressed Ok or Cancel :)
Solution:-
This code goes in the <head> tags:-
<SCRIPT language="JavaScript">
function Confirm_Ok_Cancel()
{
var Ok_Cancel= confirm("Press Ok or Cancel!");
if (Ok_Cancel== true)
{
alert("You pressed Ok");
}
else
{
alert("You Pressed Cancel");
}
}
</SCRIPT>
And this as your body:-<body onLoad="Confirm_Ok_Cancel()">
Explanation:-
I think it's self explanatory no need of explanations!
A Preview:-

Conclusion:-
As Always Feedback is welcome and the full source is attached!!


Sign In
Create Account



Back to top









