New Feature: .setLinkTarget()

July 5, 2006

We launched the Google AJAX Search API as a Version 0.1 so that we could take a little bit of time to gather feedback from developers. We've been reading the developer forum and taking note of your feedback on the current API, as well as suggestions that would make integrating it into your applications easier and more seamless.

One feature that several people have requested is the ability to control link targets in the search results, since links were being uniformly created with target="_blank". We just updated our servers to support new functions that control the value of the target attribute in generated links.

The search control object now supports a .setLinkTarget method which accepts

  • GSearch.LINK_TARGET_BLANK - open links in a new window

  • GSearch.LINK_TARGET_SELF - open links in the current frame

  • GSearch.LINK_TARGET_TOP - open links in the top most frame

  • GSearch.LINK_TARGET_PARENT - open links in the parent or top most frame

  • frame-name - open links in the specified frame

To create a search control and program it to open links in the current frame, use the following code sequence:

    var sc = new GSearchControl();

For those of you using raw searcher objects, independent of the search control, the .setLinkTarget() method is available on searchers as well:

    var searcher = new GwebSearch();

The default value for link targets is GSearch.LINK_TARGET_BLANK that will cause links to open in a new window.

Thank you for your feedback, suggestions, and ideas. Please keep them coming.