4

A bookmarklet: dataURI, please!

 3 years ago
source link: https://www.phpied.com/a-bookmarklet-datauri-please/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Ever had a string of a data URI image and you want to see said image? Simple: type data:image/png;base64, followed by the base 64 string. Except... it's too much syntax to remember. I mean c'mon: colon, semi-colon, comma. And you probably don't do this often enough. A bookmarklet is called for to aid the memory. Here goes:

location='data:image/png;base64,'+prompt('dataURIplz:');

If you think this is a good idea, drag this link to your bookmarks.

dataURIplz

Update

p.s. Doesn't work in Chrome, because you're "Not allowed to navigate top frame to data URL". If it's that important to you, maybe change the bookmarklet code to do something like:

var i = new Image();
i.src = 'data:image/png;base64,'+prompt('dataURIplz:');
document.body.innerHTML = i.innerHTML;

p.p.s. Yup, some of us write up a whole thing about a chunk of code and only then test it in that other browser that peeps seem to use.

Tell your friends about this post on Facebook and Twitter


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK