Base64 and Pictures ~

Source: Internet
Author: User

Base64, which can be identified as one of the data URI scheme types.

There are several types of Data URI scheme that can be identified, as follows:

Data:, Text
Data:text/plain, Text data
data:text/html,html Code
DATA:TEXT/HTML;BASE64,BASE64 encoded HTML code
DATA:TEXT/CSS,CSS Code
Data:text/css;base64,base64 coded CSS Code
Data:text/javascript,javascript Code
DATA:TEXT/JAVASCRIPT;BASE64,BASE64 encoded JavaScript code
DATA:IMAGE/GIF;BASE64,BASE64 encoded GIF image data
DATA:IMAGE/PNG;BASE64,BASE64 encoded PNG image data
DATA:IMAGE/JPEG;BASE64,BASE64 encoded JPEG image data
DATA:IMAGE/X-ICON;BASE64,BASE64 encoded icon image data

Picture +base64 is a way to quickly load pictures, and it saves a lot of bytes from the back end.

However, IE6 and IE7 do not support this approach.

The wording is as follows:

XADFASDFASDFASDX let this heap represent a picture of the Base64 encoding.


This thing is actually very old. Today I came up with a compatibility issue and decided to make it clear. But I found several ways, all related to MHTML.

1<!--
2content-type:multipart/related; boundary= "=_data-uri"
3 -
4<!DOCTYPE HTML>
5 <HTML>
6<Head>
7<styletype= "Text/css">
8 #pic{
9width:670px;Height:710px;
TenBackground-image:expression ("url (mhtml:" + window.location + "!locoloco)");
One}
A</style>
-</Head>
-<Body>
the
- <DivID= "Pic" ></Div>
-<DivID=teststyle= "Display:none;">
-
+--=_data-uri
-Content-location:locoloco
+Content-transfer-encoding:base64
A
atIVBORW0KGGOAAAANSUHEUGAAAAUAAAAFCAYAAACNBYBLAAAAHELEQVQI12P4//8/ w38giaxdibke0dhxgljnbaao9txl0y4ohwaaaabjru5erkjggg==
---=_data-uri--
-
- </Div>
-</Body>
-</HTML>View Code

This is a very hack way, do not recommend this, there is the asynchronous request back data, so feel very bad play.

If not compatible, you can only think of other methods.

Because to make the picture is a two-dimensional code, so re-agreed interface, by JS directly generated two-dimensional code. So other problems arise. JS generate two-dimensional code components to one.

And then it's done.

Base64 and Pictures ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.