Submitting a form and do not override location.href in a submit button click handler - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

Submitting a form and do not override location.href in a submit button click handler

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
    function redirect() {/*w  ww .j  a  v a  2  s. c om*/
        window.location.href = "http://www.example.com";
        return false;
    }

      </script> 
   </head> 
   <body> 
      <form method="GET" action=""> 
         <input type="submit" id="submitbtn" value="Submit" onclick="return redirect()"> 
      </form>  
   </body>
</html>

Related Tutorials