2019-11-02 00:06:25 +01:00
|
|
|
const favicon_selector = 'link[rel="shortcut icon"]';
|
2014-03-13 17:44:43 +01:00
|
|
|
|
|
|
|
// We need to reset the favicon after changing the
|
|
|
|
// window.location.hash or Firefox will drop the favicon. See
|
|
|
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=519028
|
|
|
|
exports.reset = function () {
|
|
|
|
$(favicon_selector).detach().appendTo('head');
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.set = function (url) {
|
2016-08-24 21:52:09 +02:00
|
|
|
if (/webkit/i.test(navigator.userAgent)) {
|
2014-03-13 17:44:43 +01:00
|
|
|
// Works in Chrome 22 at least.
|
|
|
|
// Doesn't work in Firefox 10.
|
|
|
|
$(favicon_selector).attr('href', url);
|
|
|
|
} else {
|
|
|
|
// Delete and re-create the node.
|
|
|
|
// May cause excessive work by the browser
|
|
|
|
// in re-rendering the page (see #882).
|
|
|
|
$(favicon_selector).remove();
|
|
|
|
$('head').append($('<link>')
|
2017-10-18 19:16:41 +02:00
|
|
|
.attr('rel', 'shortcut icon')
|
2014-03-13 17:44:43 +01:00
|
|
|
.attr('href', url));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-10-25 09:45:13 +02:00
|
|
|
window.favicon = exports;
|