data-uri

Is embedding background image data into CSS as Base64 good or bad practice?

孤街浪徒 提交于 2019-11-26 09:09:27
I was looking at the source of a greasemonkey userscript and noticed the following in their css: .even { background: #fff url(data:image/gif;base64,R0lGODlhBgASALMAAOfn5+rq6uvr6+zs7O7u7vHx8fPz8/b29vj4+P39/f///wAAAAAAAAAAAAAAAAAAACwAAAAABgASAAAIMAAVCBxIsKDBgwgTDkzAsKGAhxARSJx4oKJFAxgzFtjIkYDHjwNCigxAsiSAkygDAgA7) repeat-x bottom} I can appreciate that a greasemonkey script would want to bundle anything it can within the source as opposed to host it on a server, that's obvious enough. But since I had not seen this technique previously, I considered its use and it seems appealing for a number of

Is there any way to specify a suggested filename when using data: URI?

淺唱寂寞╮ 提交于 2019-11-26 05:40:14
问题 If for example you follow the link: data:application/octet-stream;base64,SGVsbG8= The browser will prompt you to download a file consisting of the data held as base64 in the hyperlink itself. Is there any way of suggesting a default name in the markup? If not, is there a JavaScript solution? 回答1: Use the download attribute: <a download='FileName' href='your_url'> Live example on html5-demos.appspot.com/.... Currently works on Chrome, Firefox, Edge, Opera, and desktop Safari but not iOS Safari

How to create a Web Worker from a string

邮差的信 提交于 2019-11-26 04:59:10
问题 How can I use create a Web worker from a string (which is supplied via a POST request)? One way I can think of, but I\'m not sure how to implement it, is by creating a data-URI from the server response, and passing that to the Worker constructor, but I\'ve heard that some browsers don\'t allow this, because of the same origin policy. MDN states the uncertainty about the origin policy around data URI\'s: Note: The URI passed as parameter of the Worker constructor must obey the same-origin

What is Data URI support like in major email client software?

不问归期 提交于 2019-11-26 04:24:45
问题 Data URIs are a standard way to embed images and other binary data in HTML, and browser support is well documented on the web. (IE8 was the first version of IE to support Data URI, with a max 32 KB size per URI; other major browsers have supported it even longer.) My question is about desktop email and webmail client software. When building HTML email, standard practice is either to include images as attachments or load them externally (i.e. tracking images). Both of these have disadvantages

Convert HTML to data:text/html link using JavaScript

梦想与她 提交于 2019-11-26 04:18:31
问题 Here\'s my HTML: <a>View it in your browser</a> <div id=\"html\"> <h1>Doggies</h1> <p style=\"color:blue;\">Kitties</p> </div> How do I use JavaScript to make the href attribute of my link point to a base64 encoded webpage whose source is the innerHTML of div#html ? I basically want to do the same conversion done here (with the base64 checkbox checked) except for in JavaScript. 回答1: Characteristics of a data-URI A data-URI with MIME-type text/html has to be in one of these formats: data:text

PHP Data-URI to file

霸气de小男生 提交于 2019-11-26 04:17:16
问题 I have a data URI I am getting from javascript and trying to save via php. I use the following code which gives a apparently corrupt image file: $data = $_POST[\'logoImage\']; $uri = substr($data,strpos($data,\",\")+1); file_put_contents($_POST[\'logoFilename\'], base64_decode($uri)); data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs 9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAxklEQVQYlYWQMW7CUBBE33yITYUUmwbOkBtEcgUlTa7COXIVV5RUkXKC5AxU EdyZVD4kyKxkwIrr9vd0c7Oih

Drawing an image from a data URL to a canvas

自作多情 提交于 2019-11-26 01:42:57
问题 How can i open an image in a Canvas ? which is encoded I am using the var strDataURI = oCanvas.toDataURL(); The output is the encoded base 64 image. How can i draw this image on a canvas? I want to use the strDataURI and create the Image ? Is it poosible ? If its not then what possibly can be the solution for loading the image on a canvas ? 回答1: Given a data URL, you can create an image (either on the page or purely in JS) by setting the src of the image to your data URL. For example: var img

Should setting an image src to data URL be available immediately?

♀尐吖头ヾ 提交于 2019-11-26 00:37:06
问题 Consider the following (fragile) JavaScript code: var img = new Image; img.src = \"data:image/png;base64,...\"; // Assume valid data // Danger(?) Attempting to use image immediately after setting src console.log( img.width, img.height ); someCanvasContext.drawImage( img, 0, 0 ); // Danger(?) Setting onload after setting src img.onload = function(){ console.log(\'I ran!\'); }; The Question(s) Should the image width and height be correct immediately? Should the canvas draw work immediately?

Drawing an image from a data URL to a canvas

让人想犯罪 __ 提交于 2019-11-25 19:23:55
How can i open an image in a Canvas ? which is encoded I am using the var strDataURI = oCanvas.toDataURL(); The output is the encoded base 64 image. How can i draw this image on a canvas? I want to use the strDataURI and create the Image ? Is it poosible ? If its not then what possibly can be the solution for loading the image on a canvas ? Phrogz Given a data URL, you can create an image (either on the page or purely in JS) by setting the src of the image to your data URL. For example: var img = new Image; img.src = strDataURI; The drawImage() method of HTML5 Canvas Context lets you copy all