CodeLab
Tutorials For Everyone
Run
<!DOCTYPE html> <html> <head> <title>JavaScript window.alert() Function Tutorial - TutsInsider</title> <style> .main{ padding: 10px; } .main-heading{ background: #333333; color: #ffffff; padding: 20px; } .main-paragraph{ margin-top: -20px; padding: 20px; box-shadow: inset 0 0 3px 0 #2a73cc; } .main-button{ padding: 5px 10px; margin: 5px; border: none; border-radius: 5px; background: #333333; color: #ffffff; box-shadow: 0 0 3px 0 #333333; cursor: pointer; } </style> </head> <body> <div class="main"> <h2 class="main-heading">What is JavaScript window.alert() Method?</h2> <div class="main-paragraph"> The JavaScript window.alert() function is used to display the data inside a popup alert. We can also utilize the alert() function without the keyword winodw as it is optional. <br /> <strong>Number of Weeks to Learn JavaScript: </strong> <br /> <button onclick="alertWithWindow()" class="main-button">With window Keyword</button> <button onclick="alertWithoutWindow()" class="main-button">Without window Keyword</button> </div> </div> <script> function alertWithWindow(){ window.alert("Weeks Needed to Learn JavaScript Programming : " + 12 ) } function alertWithoutWindow(){ window.alert("Weeks Needed to Learn JavaScript Programming : " + 12 ) } </script> </body> </html>