Skip to content

Instantly share code, notes, and snippets.

@jeandcr
Forked from mathiasbynens/change-favicon.js
Created March 15, 2019 13:59
Show Gist options
  • Select an option

  • Save jeandcr/484cfc0f6c135edddd8b681c63a5bec3 to your computer and use it in GitHub Desktop.

Select an option

Save jeandcr/484cfc0f6c135edddd8b681c63a5bec3 to your computer and use it in GitHub Desktop.

Revisions

  1. @mathiasbynens mathiasbynens revised this gist Apr 29, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion change-favicon.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    */

    // HTML5™, baby! http://mathiasbynens.be/notes/document-head
    document.head || document.head = document.getElementsByTagName('head')[0];
    document.head || (document.head = document.getElementsByTagName('head')[0]);

    function changeFavicon(src) {
    var link = document.createElement('link'),
  2. @mathiasbynens mathiasbynens revised this gist Apr 29, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion change-favicon.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    */

    // HTML5™, baby! http://mathiasbynens.be/notes/document-head
    document.head = document.head || document.getElementsByTagName('head')[0];
    document.head || document.head = document.getElementsByTagName('head')[0];

    function changeFavicon(src) {
    var link = document.createElement('link'),
  3. @mathiasbynens mathiasbynens renamed this gist Apr 29, 2011. 1 changed file with 2 additions and 15 deletions.
    17 changes: 2 additions & 15 deletions ...mically changing favicons with JavaScript → change-favicon.js
    Original file line number Diff line number Diff line change
    @@ -7,16 +7,6 @@
    // HTML5™, baby! http://mathiasbynens.be/notes/document-head
    document.head = document.head || document.getElementsByTagName('head')[0];

    // Browser sniffing :`(
    // Need to match Chromium and Chrome
    if (/Chrom/.test(navigator.userAgent)) {
    var isChrome = 1,
    iframe = document.createElement('iframe');
    iframe.src = 'about:blank';
    iframe.style.display = 'none';
    document.body.appendChild(iframe);
    };

    function changeFavicon(src) {
    var link = document.createElement('link'),
    oldLink = document.getElementById('dynamic-favicon');
    @@ -25,9 +15,6 @@ function changeFavicon(src) {
    link.href = src;
    if (oldLink) {
    document.head.removeChild(oldLink);
    };
    }
    document.head.appendChild(link);
    if (isChrome) {
    iframe.src += '';
    };
    };
    }
  4. @mathiasbynens mathiasbynens revised this gist Jun 7, 2010. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Dynamically changing favicons with JavaScript
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,8 @@
    document.head = document.head || document.getElementsByTagName('head')[0];

    // Browser sniffing :`(
    if (/Chrome/.test(navigator.userAgent)) {
    // Need to match Chromium and Chrome
    if (/Chrom/.test(navigator.userAgent)) {
    var isChrome = 1,
    iframe = document.createElement('iframe');
    iframe.src = 'about:blank';
  5. @mathiasbynens mathiasbynens created this gist Jun 7, 2010.
    32 changes: 32 additions & 0 deletions Dynamically changing favicons with JavaScript
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    /*!
    * Dynamically changing favicons with JavaScript
    * Works in all A-grade browsers except Safari and Internet Explorer
    * Demo: http://mathiasbynens.be/demo/dynamic-favicons
    */

    // HTML5™, baby! http://mathiasbynens.be/notes/document-head
    document.head = document.head || document.getElementsByTagName('head')[0];

    // Browser sniffing :`(
    if (/Chrome/.test(navigator.userAgent)) {
    var isChrome = 1,
    iframe = document.createElement('iframe');
    iframe.src = 'about:blank';
    iframe.style.display = 'none';
    document.body.appendChild(iframe);
    };

    function changeFavicon(src) {
    var link = document.createElement('link'),
    oldLink = document.getElementById('dynamic-favicon');
    link.id = 'dynamic-favicon';
    link.rel = 'shortcut icon';
    link.href = src;
    if (oldLink) {
    document.head.removeChild(oldLink);
    };
    document.head.appendChild(link);
    if (isChrome) {
    iframe.src += '';
    };
    };