Avoid the pageload after clicking the ok button in alert box - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

Avoid the pageload after clicking the ok button in alert box

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <a href="somepage.htm" onclick="return showAlert(&quot;Some Book Title&quot;);">Title</a> 
      <script>
        function showAlert(title){
            console.log('You dont have Access to: ' + title);
            return false;/* w  ww  .j av a2 s.c o m*/
        }
    
      </script>  
   </body>
</html>

Related Tutorials