How to create a search box that open multiple search results from different search engines in multiple tabs?
-
I need a search box and a submit button that will open my input in multiple tabs as the search result from multiple search engines. Thanks.
-
Answer:
The way you described what you want to do does not require you to use Ajax. Ajax is for loading data from the web and updating parts of the page that the user is on, with Ajax you can update the page without moving to a new page. Since you asked to open new tabs, Ajax has nothing to do with it. <html> <head> <script type="text/javascript"> function performSearch() { var searchTerm = encodeURIComponent(document.getElementById('searchField').value); window.open('http://www.google.com/search?q=' + searchTerm, 'new_window_1'); window.open('http://search.yahoo.com/search?p=' + searchTerm, 'new_window_2'); // open more tabs here ... } </script> </head> <body> <input id="searchField" type="text" /> <input type="button" value="click me" onclick="performSearch();" /> </body> </html> Can you tell me how to make the search field to perform search after pressing enter? The quick way: if we make our text field a part of an actual HTML form, and make our javascript function run when the user submits the form - that will cause the function to run when the user clicks enter inside the text field, because clicking enter inside a text box that is part of a form submits the form. <html> <head> <script type="text/javascript"> function performSearch() { var searchTerm = encodeURIComponent(document.getElementById('searchField').value); window.open('http://www.google.com/search?q=' + searchTerm, 'new_window_1'); window.open('http://search.yahoo.com/search?p=' + searchTerm, 'new_window_2'); // open more tabs here ... } </script> </head> <body> <form onsubmit="performSearch(); return false;"> <input id="searchField" type="text" /> <input type="submit" value="click me" /> </form> </body> </html> Now the type of the button input is 'submit', so when the user clicks the button the form should get submitted, and we have an event handler on the form - the 'onsubmit' - this runs when the user clicks the button or presses enter inside the search field. We add 'return false;' so that nothing actually happens after our function runs - the form doesn't actually get submitted (because when you submit a form you usually send information somewhere, we don't do that here, it's like a pseudo-form).
INeedCodes at Stack Overflow Visit the source
Other answers
you need to use ajax and grab the content sending the query string using GET method and showing it in Div or whatever you want ! when i searched for AJAX Micro Mini Lib google redirected me to http://www.google.co.in/search?q=ajax+micro+mini&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a Now omit all those things which you dont want that is http://www.google.co.in/search?q=encodeURIComponent(searchString) Now use AJAX Micro Mini or jQuery or what ever to get the content of the page, you can use AJAX Micro Mini [if you know PHP or ASP or JSP ...], as it comes with some simple example
Sourav
Related Q & A:
- How to create a generic View for different Models?Best solution by Stack Overflow
- How to create a CakePHP search form?Best solution by Stack Overflow
- How do I add my website to the AOL, MSN, and Ask.com search engines?Best solution by Yahoo! Answers
- How do i get my web site listed in search results?Best solution by Yahoo! Answers
- What are the different search engines?Best solution by wiki.answers.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.