From f13806fa5c1c366b5eda685b2f2addc1328a1053 Mon Sep 17 00:00:00 2001 From: antisnatchor Date: Tue, 26 Apr 2011 09:35:23 +0000 Subject: [PATCH] (Fixes issue 288): now changeFavicon works in Firefox, Chrome and Opera git-svn-id: https://beef.googlecode.com/svn/trunk@928 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9 --- core/main/client/browser.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/core/main/client/browser.js b/core/main/client/browser.js index 68cefcc1d..128490e22 100644 --- a/core/main/client/browser.js +++ b/core/main/client/browser.js @@ -592,14 +592,28 @@ beef.browser = { }, /** - * Changes the favicon in firefox only + * Dynamically changes the favicon: works in Firefox, Chrome and Opera **/ changeFavicon: function(favicon_url) { - var link = document.createElement('link'); - link.type = 'image/x-icon'; - link.rel = 'shortcut icon'; - link.href = favicon_url; - document.getElementsByTagName('head')[0].appendChild(link); + var iframe = null; + if (this.isC()) { + iframe = document.createElement('iframe'); + iframe.src = 'about:blank'; + iframe.style.display = 'none'; + document.body.appendChild(iframe); + } + var link = document.createElement('link'), + oldLink = document.getElementById('dynamic-favicon'); + link.id = 'dynamic-favicon'; + link.rel = 'shortcut icon'; + link.href = favicon_url; + if (oldLink) { + document.head.removeChild(oldLink); + } + document.head.appendChild(link); + if (this.isC()) { + iframe.src += ''; + } }, /**