First page Back Continue Last page Image
- <!DOCTYPE html>
- <html>
- <head>
- <title>
- My JavaScript page
- </title>
- <script>
- if (confirm("Are you sure you want to do that?")) {
- alert("You said yes");
- }
- else {
- alert("You said no");
- }
- </script>
- </head>
- <body>
- <noscript>
- <h2>This page requires JavaScript.</h2>
- </noscript>
- </body>
- </html>
- In this example we use a confirm and alert functions. We will talk about functions next
- In JavaScript the Then (True) case is inside the first { curly braces} after the test
- In JavaScript the Else (False) case is inside the first { curly braces} after the Else