|
JavaScript Confirm function |
Recently I've been using the JavaScript confirm method to confirm if a user has clicked on the right thing or not. A handy 'catch-and-verify' fail safe.
I was doing it like this (the old fashioned way):
2function confirm()
3{
4var r=confirm("Press a button");
5if (r==true)
6 {
7 document.write("You pressed OK!");
8 }
9else
10 {
11 document.write("You pressed Cancel!");
12 }
13}
14</script>
15</head>
16<body>
17
18<input type="button" onclick="confirm()" value="Display a confirm box" />
I've since discovered that you can do this in a much easier shorthand kind of way:
this performs the same confirm alert, and if true, sends the user on to the url in the hyperlink. Much shorter!
There are no comments for this entry.
[Add Comment] [Subscribe to Comments]