Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get Google Search API results href values using jquery
    primarykey
    data
    text
    <p>I am using the simple Google API to display search results. I would like to get the href value of a link on mouseover or click. It is really not important what flavor of javascript is used, I just need to get the user selected href value of the rendered search.</p> <p>(I need this as I have a webservice that allows users to save links they find of interest.)</p> <p>I am horrible at client side scripting so I could really use a hand. With the example here I using the default Google AJAX Search API Sample.</p> <p><a href="http://www.thesupermedia.com/test/googlesearch/jquerymouseover2.GIF" rel="nofollow noreferrer">To visually explain I have posted this image.</a> (cannot attach)</p> <p>I have used the link - <a href="https://stackoverflow.com/questions/2098408/how-to-get-href-value-using-jquery">How to get href value using jQuery?</a> - for simple reference to no avail. I believe it is due to the way/page render order that the google search results are displayed. </p> <p>The html source pre render is as follows:</p> <pre><code> &lt;!-- copyright (c) 2009 Google inc. You are free to copy and use this sample. License can be found here: code.google.com/apis/ajaxsearch/faq/#license --&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="content-type" content="text/html; charset=utf-8"/&gt; &lt;title&gt;Google AJAX Search API Sample&lt;/title&gt; &lt;script src="http://www.google.com/jsapi?key=AIzaSyA5m1Nc8ws2BbmPRwKu5gFradvD_hgq6G0" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; /* * How to do a search that returns the max number of results per page. */ google.load('search', '1'); function OnLoad() { // create a search control var searchControl = new google.search.SearchControl(); // Set the Search Control to get the most number of results searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET); // Create 2 searchers and add them to the control searchControl.addSearcher(new google.search.WebSearch()); searchControl.addSearcher(new google.search.BlogSearch()); // Set the options to draw the control in tabbed mode var drawOptions = new google.search.DrawOptions(); drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED); // Draw the control onto the page searchControl.draw(document.getElementById("content"), drawOptions); // Search! searchControl.execute("Subaru STI"); } google.setOnLoadCallback(OnLoad); &lt;/script&gt; &lt;/head&gt; &lt;body style="font-family: Arial;border: 0 none;"&gt; &lt;div id="content"&gt;Loading...&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; The relevent rendered result html source is as follows: &lt;div class="gs-webResult gs-result"&gt; &lt;div class="gs-title"&gt; &lt;a class="gs-title" href="http://en.wikipedia.org/wiki/Subaru_Impreza_WRX_STI" target="_blank"&gt; &lt;b&gt;Subaru&lt;/b&gt; Impreza WRX &lt;b&gt;STI&lt;/b&gt; - Wikipedia, the free encyclopedia&lt;/a&gt;&lt;/div&gt; </code></pre> <p>If anyone can point me in the right direction I would really appreciate it. Thanks a million, Dave</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload