More results target link

5 views
Skip to first unread message

bronson

unread,
Jul 15, 2008, 4:44:05 AM7/15/08
to Google AJAX API
Hi every body,

I can't figure out how to set up the script to make pointing the more
results (from a web search or else) to the same target than four first
pages results target.

Apparently, the native target is "_blank"? Can we change this, if so,
how ?

Many thanks
Rgds.

Ben Lisbakken

unread,
Jul 15, 2008, 12:52:50 PM7/15/08
to Google-AJAX...@googlegroups.com
Hey Bronson --

You are supposed to keep the more link to point to Google.  However, if you just want to make it so that it doesn't open a new window then you could use DOM traversing to grab the link, then set the target to be nothing.

The quickest to write (and least efficient to run) would be to do something like:
var anchors = document.getElementsByTagName('a');
for (var i = 0; i < anchors.length; i++) {
  if (anchors[i].href == TheMoreLinkHref && anchors[i].target == "_blank") {
    anchors[i].target = "";
    break;
  }
}

-Ben

bronson

unread,
Jul 16, 2008, 11:17:50 AM7/16/08
to Google AJAX API
Thks for your answser,

but i probably do something wrong with those Google API but i can't
make it working, still openning blank.... Strange

the link is there http://inedie.free.fr/Placement.html

Could i have a glance to the code ? Is it because "more results" is in
french ? I doubt but ...

Thanks so lot
Rgds

Bronson

On Jul 15, 6:52 pm, Ben Lisbakken <lisba...@google.com> wrote:
> Hey Bronson --
>
> You are supposed to keep the more link to point to Google.  However, if you
> just want to make it so that it doesn't open a new window then you could use
> DOM traversing to grab the link, then set the target to be nothing.
>
> The quickest to write (and least efficient to run) would be to do something
> like:
> var anchors = document.getElementsByTagName('a');
> for (var i = 0; i < anchors.length; i++) {
>   if (anchors[i].href == TheMoreLinkHref && anchors[i].target == "_blank") {
>     anchors[i].target = "";
>     break;
>   }
>
> }
>
> -Ben
>

Ben Lisbakken

unread,
Jul 16, 2008, 1:45:40 PM7/16/08
to Google-AJAX...@googlegroups.com
Bronson --

If you want the "more results" to open in the same page (or even the same div, which you could do with an iframe) you will have to write your own custom solution.  Also, you seem to not have the correct CSS included for that example.

-Ben
Reply all
Reply to author
Forward
0 new messages