I am using Ruby on Rails v3.0.9 and jQuery 1.6. I am using a JavaScript function (see the accepted answer) so to retrieve the favicon.ico icon image from some web sites.
As you can see all works good except for the http://www.gmail.com link for which I get a 301 Moved Permanently HTTP status response.

I would like to improve this JavaScript code so to follow the redirection and then try to find the favicon.ico icon image on the “redirected” URL. How can I improve that code so to correctly retrieve the favicon image?
There is nothing wrong with your JavaScript. If you try going to the favicon.ico in a browser, you’ll see that it won’t even give you the icon. The 301 Redirect is pointing to http://mail.google.com/mail/, which would just be a G-Mail inbox. There is no image at this location. This was the result from
curl -i.G-Mail is just trying to take the person to their inbox since there is nothing there. The actual location of G-Mail’s favicon.ico is https://mail.google.com/mail/images/2/mail_icon_32.png, which is set via a
metatag in the HTML source. From G-Mail’s source:You can read more about that here.