tags:

views:

337

answers:

3

I do not have server side access...

I'm trying to present a custom favicon from a hosted wiki service that provides scripting and CSS access, but presents it's own favicon to all it's users.

Is it possible to do something like this but with jQuery? If so, how?

+5  A: 

jQuery is Javascript, which runs client-side once a page has been returned.

The request for the favicon is a pure HTTP request from browser to server, no page is loaded. You can only redirect requests like that using server-side techniques (such as the one you linked to).

There are a million ways you can do it server-side (.htaccess files, php redirects, etc.) but jQuery simply is not an option.

Gabriel Hurley
100% true and upvoted. Worth mentioning that you can use `<link>` to tell the browser where to make the HTTP request from.
artlung
+1  A: 

No. The search engine spiders mentioned as issues in that post will not load and execute your JavaScript code.

ceejayoz
+4  A: 

The most reliable way is to put /favicon.ico at the root of your site. But to point to another image you can use code like this, as featured at the Wikipedia favicon page:

<link rel="icon" type="image/x-icon" href="/somepath/image.ico" />
<link rel="SHORTCUT ICON" href="/somepath/image.ico" />

Adjust the path and type value to match the image type.

No jQuery, though I suppose you could write JavaScript to inject these tags into the <head> so browsers would see them, but it seems easier just to add the html <link> tags.

artlung