Last active
December 12, 2015 07:38
-
-
Save dearfrankg/4737640 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // credit: http://snipplr.com/view.php?codeview&id=56433 | |
| // | |
| var xmlhttp = new XMLHttpRequest(); | |
| xmlhttp.open("GET",'favicon.ico',false); | |
| xmlhttp.overrideMimeType('text/plain; charset=x-user-defined'); | |
| xmlhttp.send(); | |
| var data = ''; | |
| for ( var i = 0; i < xmlhttp.responseText.length; i++ ) data += String.fromCharCode( ( xmlhttp.responseText[ i ].charCodeAt(0) & 0xff ) ); | |
| // Convert raw data to base64 | |
| data = btoa( data ); | |
| var base64src='data:image/jpg;base64,'+data; // change the MIME type according to content | |
| document.getElementById("foo").src = base64src; | |
| console.log(base64src); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment