One of the problems I had with GCSE on my blog was that it always opened links in a new window or tab. This wasn't very convenient, but I only had to change a little code in the results code.
Before Modification:
<!-- Put the following javascript before the closing </head> tag. -->
<script>
(function() {
var cx = '010940491106818468665:ak7ru-numse';
var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//' + cx;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
})();
</script>
<!-- Place this tag where you want the search results to render -->
<gcse:searchresults-only></gcse:searchresults-only>
After Modification (when the results open in same tab):
<!-- Put the following javascript before the closing </head> tag. -->
<script>
(function() {
var cx = '010940491106818468665:ak7ru-numse';
var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//' + cx;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
})();
</script>
<!-- Place this tag where you want the search results to render -->
<gcse:searchresults-only linktarget="_parent"></gcse:searchresults-only>
I replaced
<gcse:searchresults-only> with
<gcse:searchresults-only linktarget="_parent">.
Hi Seth,
ReplyDeleteI am adding GCSE to a website using the code provided by google. I have searchresults in one td of table.
I want the same search results(only the links/and its text) to be available in another td. How do I do that?
My email is nayakga@gmail.com
Regards
Ganesh
http://sethsdiscoveries.blogspot.com/2012/10/two-page-more-customizable-gcse-for.html may answer your question. It's given for blogger, but should work for any website.
ReplyDeleteJust paste the results code into both tds.
If you could give me a link to your page, it would help.
sethsevenyoln@aol.com
Thank You so Mych you saved my day!
ReplyDelete