Your problem is found on the line reading searchControl.addSearcher(new google.search.WebSearch(), options); . Change that line to the following, and it should work:
searchControl.addSearcher(webSearch, options); The reason for this is that you placed the site restriction on the WebSearch object you created above, but you're putting a new WebSearch object into the search control. Jeremy R. Geerdes Effective website design & development Des Moines, IA For more information or a project quote: http://jgeerdes.home.mchsi.com http://jgeerdes.blogspot.com http://jgeerdes.wordpress.com [email protected] Unless otherwise noted, any price quotes contained within this communication are given in US dollars. If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church! And check out my blog, Adventures in Web Development, at http://jgeerdes.blogspot.com ! On Jun 6, 2009, at 5:13 AM, Franko wrote: > > Hi there, > > I am fairly new to Google Ajax APIs and in fact relatively new to AJAX > anyway. > > I am learning by simply practicing on one of my sites and am trying to > come up with code that will do a simple restricted site search and > then put the results on a different part of the page. > > Basically trying to combine the Set Site Restrict and the Search > Result Placement code examples. > > Despite spending way too many hours trying to figure it out, I have > got stuck and am hoping for a steer please. I can place the search bow > where I want and place the results where I want but for some reason I > have not been able get it to restrict it to a single site. > > > Here is my current code and any help would be vvery gratefully > received please.... > > google.load('search', '1'); > function OnLoad() { > // Create a search control > var searchControl = new google.search.SearchControl(); > > // Add in a WebSearch > var webSearch = new google.search.WebSearch(); > > // Restrict our search to pages from the Pack a Mail > webSearch.setSiteRestriction('www.packamail.co.uk'); > > // web search, open, alternate root > var options = new google.search.SearcherOptions(); > options.setExpandMode > (google.search.SearchControl.EXPAND_MODE_OPEN); > options.setRoot(document.getElementById("somewhere_else")); > //options.setSiteRestriction('www.packamail.co.uk'); > searchControl.addSearcher(new google.search.WebSearch(), > options); > > // tell the searcher to draw itself and tell it where to attach > searchControl.draw(document.getElementById("content")); > // execute an inital search > searchControl.execute(''); > } > google.setOnLoadCallback(OnLoad); > > > > Thank you! > > Paul > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google AJAX APIs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-AJAX-Search-API?hl=en -~----------~----~----~----~------~----~------~--~---
