Created
December 8, 2014 16:57
-
-
Save dbader/3f9adca03e655b90c2b8 to your computer and use it in GitHub Desktop.
Dynamic favicons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var canvas = document.createElement('canvas'); | |
var ctx = canvas.getContext('2d'); | |
canvas.width = 16; | |
canvas.height = 16; | |
ctx.fillStyle = '#F00'; // <- Pick a colour. | |
ctx.fillRect(0, 0, canvas.width, canvas.height); | |
var favicon = document.getElementsByTagName('link')[0]; | |
favicon.href = canvas.toDataURL(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment