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

  • SEARCH
  • Home
  • 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 3938154
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:09:06+00:00 2026-05-20T00:09:06+00:00

I’m doing some Mac development in a WebView. I want to expand URLs that

  • 0

I’m doing some Mac development in a WebView. I want to expand URLs that have been shortened by a url shortener, and display that expanded URL to the user. So, given a link whose src attribute is set to http://is.gd/xizMsr, when the user hovers over the link I want the title tooltip to display http://google.com

My link tag looks like this:

<a href="http://is.gd/xizMsr" onMouseOver="myFunction(this);">Here's a shortened link to google</a>

And here’s the relevant javascript, which will use XMLHttpRequest to fetch the expanded URL and then update the title

var myRequest;
var mousedOverElement;
var isLoading = false;

function myFunction(anObject) {
  if (isLoading == false) {

    isLoading = true;
    mousedOverElement = anObject;
    var link = anObject.getAttribute('href');
    var encodedURL = encodeURI(link);
    var url = 'http://is.gd/forward.php?format=simple&shorturl=' + encodedURL;

    myRequest = new XMLHttpRequest();
    myRequest.open("GET", url);
    myRequest.onreadystatechange = onStateChange;
    myRequest.send();
  }
}

function onStateChange()  {
    if (myRequest.readyState==4) { 
        if (myRequest.status==200) {   
            mousedOverElement.setAttribute('title',myRequest.responseText);
        }

        isLoading = false;
    }
}

The problem is, when I hover over the link, and then stop moving the cursor, the title attribute is set properly, but the tooltip is not shown. I have to move the mouse again to make the tooltip show up. I don’t necessarily have to move the cursor off of the link and then back over it, but simply moving a few pixels while remaining hovered over the link will do the trick.

I know that the title is being set properly from a combination of using the Web Inspector and the Javascript debugger in Safari. In fact, pretty much as soon as I hover over the link, I see the Web Inspector’s view of the DOM in the “elements” tab update with the new title. But, if I take my hand off of the mouse, the tooltip never shows.

My assumption here is that WebKit only shows a tooltip when the user is moving the mouse. Is there a way to sort of “wake up” webkit, even if the cursor is not moving? Or am I better off implementing this with some of my own DHTML-ish magic instead of relying on the title attribute?

  • 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-20T00:09:06+00:00Added an answer on May 20, 2026 at 12:09 am

    What about an element (move it over the anchor) or a wrapper (positive z-index) with a transparent background which will (onmouseover):

    1. first add the anchor’s title (you will have to modify your function)
    2. and then change its (negative for the covering element) z-index (effectively putting the anchor in the foreground)

    This way the title will be readily available. If necessary you can add a setTimeout() between step 1 and 2.

    Or you could simply use setAttributeNode to modify the title attribute value.

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

Sidebar

Related Questions

i want to parse a xhtml file and display in UITableView. what is the
I need to clean up various Word 'smart' characters in user input, including but
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.