Wednesday, October 14, 2009

Google Custom Search Results per Page

If you are using Google Custom Search on your site, you may wonder how to change the count of search results per page. Okay, if you take a look at the custom search form html code, you will find this line

<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>

Now open this script in browser and look into the code itself. This line does the trick

h=(h=b.googleNumSearchResults)?Math.min(h,20):10

It checks if the variable googleNumSearchResults exists and if true, the count of search results per page will be set to minimum value from googleNumSearchResults and 20. If the googleNumSearchResults is not set, the count of search results per page will be set to 10. So you can easily customize the results count by adding this line to your custom search form code (remember you can't get more than 20 results per page)

var googleNumSearchResults = 15;

2 comments:

  1. I found above info incorrect. May be its outdated. Kindly post something working...in 2012.

    ReplyDelete