How To Change The Iframe Width In Google’s Custom Search Results


How To Change The Iframe Width In Google’s Custom Search Results

The search function is powered by the CSE (Google Custom Search Engine) and is the highly customizable search engine ho helps the blogs and websites.

Did you asked how the search results are displayed ? Well the hosting option determines that and it display’s those results ( either via a search element overlay, iframe, or Google-hosted page.)

Mostly the webmasters choose to show search results in the iframe this because it will blend in to the site’s template better.

In order to modify the width of the iframe well is not so easy this I can tell you.

So you need to change the which of the frame that shows the search results, go ahead and change the value in the search results code snippet:

var googleSearchFrameWidth = 600

  1. The default of the width is 600pixels, now increase or decrease the size in order to achieve the match of the design in the site.

  2. There is a limitation for the how small the iframe can get.

  3. The iframes that has some advertising on the “Top” or the “Bottom” the minimum width is 500 pixels.

  4. The iframes that have ads on the “right” or “Top and Right” need to have the width of 795 pixels.

  5. So you need to tweak that iframe then you need to do a hack on the show_afs_search.js is required

  6. I got just the thing for you follow this few steps in order to edit the “show_afs_serch.js”, “self_host” plus how to get to display search results in iframe

  7. Not please download and then save the “show_afs_search.js” from here you can download.

  8. Now all is required of you is to edit “show_afs_search” use any ordinary text editor.

  9. Simply choose to do the following ways in order to achieve the hack to iframe at any width:

  10. Now just replace the following codes.

  11. Width:c to width:”600″.

  12. At the 600 you need to replace the width with the size you chose in pixels not to forget.

  13. Do not forget to replace the 795 or 500 needs to coincide with the cof’s FORID value tag.

  14. The search box go ahead and take the fragment the code below and replace the size required width in pixels with value: ”var c={“9″:795,”10″:795,”11″:500}”

  15. Here is the trick to reduce the minimum width needed.

  16. Each of the three ads they display location supported

  17. And the value of the needed size still needs to be set properly in the googleSearchFrameWidth variable in the search results.

  18. Follow the line of this code: d={name:”googleSearchFrame”,src:d,frameBorder:g.googleSearchFrameborder,width:c,height:b,marginWidth:”0?,marginHeight:”0?,hspace:”0?,vspace:”0?,allowTransparency:”true”,scrolling:”no”}

  19. Slimly Change:Width:a To Width:googleSearchFrameWidth.

  20. By doing the trick above you will force the search results from iframe to just display in the width that is defined by googleSearchFrameWidth variable.

  21. Just save the modified show_afs_search.js

  22. Now upload the edited show_afs_search.js where the search results page are saved.

  23. Do not worry is able to upload to any public location that accessible by the Internet but you must mention full path to the file as I made in the steps bellow:

  24. <script type=”text/javascript” src=”//”></script>

  25. Modify to : <script type=”text/javascript” src=”//full/path/to/show_afs_search.js”></script>

  26. Or you can also change it to : <script type=”text/javascript” src=”show_afs_search.js”></script> (if show_afs_search.js is located in the same directory with the search results page HTML file.

With Google Custom Search, you can simply use the power of Google to create a customized search experience for your own website.

Tags: search, results, iframe, width, script, just, replace, show_afs_searchjs, pixels, change, order, value, display, type”textjavascript”, google, page, custom, size, location, variable, save, choose, required, hack, minimum, googlesearchframewidth, iframes, steps, follow, edit