Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4086982
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:47:51+00:00 2026-05-20T18:47:51+00:00

I am using the simple Google API to display search results. I would like

  • 0

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.

(I need this as I have a webservice that allows users to save links they find of interest.)

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.

To visually explain I have posted this image. (cannot attach)

I have used the link –
How to get href value using jQuery? – for simple reference to no avail. I believe it is due to the way/page render order that the google search results are displayed.

The html source pre render is as follows:

    <!--
  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
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google AJAX Search API Sample</title>
    <script src="http://www.google.com/jsapi?key=AIzaSyA5m1Nc8ws2BbmPRwKu5gFradvD_hgq6G0" type="text/javascript"></script>
    <script type="text/javascript">
    /*
    *  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);

    </script>

  </head>
  <body style="font-family: Arial;border: 0 none;">

    <div id="content">Loading...</div>

  </body>
</html>

The relevent rendered result html source is as follows: 


     <div class="gs-webResult gs-result">
                        <div class="gs-title">
                            <a class="gs-title" href="http://en.wikipedia.org/wiki/Subaru_Impreza_WRX_STI" target="_blank">
                            <b>Subaru</b> Impreza WRX <b>STI</b> - Wikipedia, the free encyclopedia</a></div>

If anyone can point me in the right direction I would really appreciate it.
Thanks a million, Dave

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:47:52+00:00Added an answer on May 20, 2026 at 6:47 pm

    I’m not quite certain about the Google library that you’re using – from what I could tell from a quick search it seems to be deprecated. You might want to link to where you’re getting the samples from.

    If you just want to extract the href on click or mouseover, you might do this:

    $('a.gs-title').live('click', function(e){
            e.preventDefault();
            console.log('clicked', $(this).attr('href'));
        });
    

    This uses jQuery’s live() event handler to attach this click-handler to every <a> element that has the class gs-title, even if it gets added to the page later (to do it on mouseover, simply change the first argument to mouseover instead of click). The handler itself does nothing but prevent the default click action (so you’ll find that the links do not work) and log the href to the console. You can adapt it to your requirements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a simple appliacation using the Google Maps API and I'm trying to
Trying to write a simple call to google's JSON stock ticker API. I would
I have a simple Google App Engine app, that I wrote using ordinary strings.
Simple question, but I haven't found a good explanation on google. When using Set
First, let's get the security considerations out of the way. I'm using simple authentication
I am serializing a class using simple-xml ( http://simple.sourceforge.net/ ) but when i try
Whenever I try to copy an entire working copy using simple drag and drop
I want to scrape some information off a football (soccer) web page using simple
The problem is simple: Using bash, I want to add a directory to my
I'm using this simple regular expression to validate a hex string: ^[A-Fa-f0-9]{16}$ As you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.