Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Multi-site searching via one search window

    Hey folks. I'm hoping someone can help with what seems like some fairly simple coding.

    I'd like to create an HTML document with a "universal search box" so that I can enter my search terms, then have them inserted into the search strings for various sites, which would open in new tabs.

    Kinda like this:

    Search terms: "Election+coverage"

    New tab #1:
    http://query.nytimes.com/search/sitesearch?query=election+coverage&srchst=cse

    New tab #2:
    http://www.youtube.com/results?search_query=election+coverage&aq=f

    So basically, after I enter my terms into the search box and hit ENTER, I need the page to take what's in that search box, insert it into several pre-defined URLs, then open each URL in a new tab.

    I can't call myself a programmer by any means, though I do know some basic HTML. Is this something that would take a lot of effort to do? If not, any ideas about how to accomplish this would be much appreciated!

  • #2
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    You could do something like this:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Example</title>
    <script type="text/javascript">
    var sites = [
    	'http://query.nytimes.com/search/sitesearch?query=[QUERY]&srchst=cse',
    	'http://www.youtube.com/results?search_query=[QUERY]&aq=f'
    	];
    
    function openQuery(q)
    	{
    	//this will only open a new tab if the user's browser is configured that way
    	for (var i=0;i<sites.length;i++) window.open(sites[i].replace('[QUERY]',q));
    	}
    
    window.onload = function()
    	{
    	document.getElementById('submit_query_btn').onclick = function()
    		{
    		openQuery(document.getElementById('query_input').value);
    		};
    	}
    </script>
    </head>
    <body>
    
    <input id="query_input" type="text" />
    <input id="submit_query_btn" type="button" value="query" />
    
    </body>
    </html>
    Last edited by itsallkizza; 10-21-2010 at 03:46 AM.
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com

  • #3
    New to the CF scene
    Join Date
    Oct 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Yes! That's EXACTLY what I was looking for. Thanks!


  •  

    Tags for this Thread

    Posting Permissions

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