Focus opened window - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window open

Description

Focus opened window

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script ="text javascript">
function check() {/*from   ww  w  .  jav a  2  s.  c  om*/
   var txtfield; txtfield =document.getElementById('txtbox').value;
   if(txtfield == "run")
   { 
     console.log("you entered string right");
     var newwin=window.open('http://java2s.com','welcome','width=500,height=500,menubar=yes,status=yes,location=yes,toolbar=yes');
     newwin.focus();
   }
   else { 
     console.log("Try again"); 
   }
}
 
      </script> 
   </head> 
   <body>
       Enter a Keayword 
      <input type="text" id="txtbox" onblur="check()">  
   </body>
</html>

Related Tutorials