Open a window and Do google search, get key word from input text field - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Open a window and Do google search, get key word from input text field

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <base target="_top"> 
      <script>
      function doSearch() {//ww w  .  j  ava  2 s.co  m
        var searchFor = document.getElementById("txtSearchFor").value;
        window.open("https://www.google.com/search?q=" + searchFor);
      }
    
      </script> 
   </head> 
   <body> 
      <h1>Sidebar</h1> 
      <input type="text" id="txtSearchFor"> 
      <input type="button" value="Search" id="btnSearch" onclick="doSearch()">  
   </body>
</html>

Related Tutorials