Reputation: 26672
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 its own favicon to all its users.
Is it possible to do something like this but with jQuery? If so, how?
Upvotes: 2
Views: 1650
Reputation: 34013
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.
Upvotes: 5
Reputation: 180024
No. The search engine spiders mentioned as issues in that post will not load and execute your JavaScript code.
Upvotes: 1
Reputation: 40052
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.
Upvotes: 5