Create a Button in a case statement to launch a url - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

Create a Button in a case statement to launch a url

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script type="text/javascript">
document.write('<button id="foo">Hai!</button>');
var foo = document.getElementById('foo');
foo.onclick = function () {
    window.open('http://java2s.com/',"_blank");
};

      </script>  
   </body>//w  ww  . j  a  v a  2s  .c  om
</html>

Related Tutorials