www.webdeveloper.com
Results 1 to 2 of 2

Thread: On submit form search the web

  1. #1
    Join Date
    Jun 2007
    Posts
    96

    On submit form search the web

    Hey Guys,

    I have made a small form for some Javscript practice because I want to get back into it - codes below. You enter a term - it opens a google search page and searches for the term + site:site.com.

    Can someone point me in the right direction for a couple of things:

    1) I'd like it to open in Chrome not IE (eww)
    2) I would like to not open a page but display the results in a frame below my form.

    If anyone has any pointers that would be great - its a good way to learn!

    Thanks,
    Liam

    Code:
    <head>
    <style type="text/css">
    
    .btnSubmit{
    cursor:pointer;
    border:outset 1px #ccc;
    background:#999;
    color:#white;
    font-weight:bold;
    padding: 1px 2px;
    margin-left: 0px;
    
    }
    </style>
    
    <style type="text/css">
    <!--
    a:link {color: #000000; text-decoration: underline; }
    a:active {color: #000000; text-decoration: underline; }
    a:visited {color: #000000; text-decoration: underline; }
    a:hover {color: #ff0000; text-decoration: none; }
    -->
    </style> 
    
    <script type="text/javascript">
    function googleSearch() {
      if (document.doingasearch.searchbox.value!="") {    
          window.open("http://www.google.com/search?hl=en&q=" + document.doingasearch.searchbox.value + " site:www.mediafire.com");        
      }
      else {
        alert("Please enter something to search.")
        document.doingasearch.searchbox.focus();
      }
    }
    </script>
    
    </head>
    <BODY link="black">
    
     <div>
     <form name="doingasearch" id="doingasearch">
    	<p style="color:black; font-family: Lucida Console; font-size:11px">Enter Search Term:</p>
    	<input type="text" name="searchbox" id="doingasearch" cols=30 rows=3 style="background-color:black; color:white; font-family: Lucida Console; font-size:11px"></input>
    	<br />
    	<br />
    	<input type="button" value="Go!" onclick="return googleSearch();">
    	
    	<br />
    	
    </form>
    	
    	
    	
    </div>
      
     </BODY>
    
    </HTML>
    Cheers,
    Liam

  2. #2
    Join Date
    Sep 2009
    Posts
    159
    For iframe part of the question, check this article out. But I don't know it is possible to let you choose which browser to open the content with.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles