Base64 encoding used in HTML (supports IE6, IE7, IE8)

Source: Internet
Author: User
Tags base64

  1. Using base64 encoding in HTML is called Data URI scheme.
  2. The currently supported types of Data URI scheme are: (2016-10-19)
    Data:, text string
    data:text/plain,%s
    data:text/html,%s
    data:text/html;base64,%s
    data:text/css,%s
    data:text/css;base64,%s
    data:text/javascript,%s
    data:text/javascript;base64,%s
    data:image/gif;base64,%s
    data:image/png;base64,%s
    data:image/jpeg;base64,%s
    data:image/x-icon;base64,%s


  3. 1) base64 encoding can be generated directly under Linux using the Base64 command line tool:
    > base64 "/USER/PRJ/64 tester/test.png"
    2) in PHP can be encoded with the function Base64_encode ():
    <?php
    $s = ' 123 ';
    Echo Base64_encode ($s);
    //Attached: Anti-compilation: Base64_decode ($s);
    ?>
    3) Use FileReader to encode the browser under HTML5:
    <input type= "file" onchange= "Readfile4base64uri (This)"/>
    <script type= "Text/javascript" >
    function Readfile4base64uri (EL) {
    var f = el.files[0];
    var reader = new FileReader ();
    Reader.readasdataurl (f);
    reader.onload = function (e) {
    var s = this.result;
    alert (s);
    //var _tmp = '
    //$ (' Preview-panel '). InnerHTML = _tmp;
        };
    }
    </script>
    4) with csharp words, you can:
    static public string base64 (string s, bool b)
    {
        /***
    *bool B, when [true] encryption, OtherWise [false] decryption
    *author:xhx jx744418777
    *ondate:20161019 [C # vs2010 WinXp SP3]
        ***/
    Try
        {
    if (b) {
    return System.Convert.ToBase64String (System.Text.Encoding.Default.GetBytes (s));
    } else {
    return System.Text.Encoding.Default.GetString (System.Convert.FromBase64String (s));
            }
    } catch (Exception exp)
        {
    return exp. Message;
         }
    return null;
    }
    5) C\c++, refer to the CSDN on:
    http://blog.csdn.net/tiandyoin/article/details/30723475
    "[to] Base64 encryption and decryption algorithm C + + code implementation"

  4. Base64 Browser Support level:
      Opera 7.2+ data URI must be less than 4100 characters
      ie8+ data uri must be less than 32k (IE8 does not support JS data uri)(with JS words to be written according to the specific browser and system,

    I write in WinXP IE6 some bugs, if only use JavaScript address to join: file://prefix line)

      No restrictions on Chrome,FF , and Safari

  5. 1)
    http://blog.csdn.net/hansel/article/details/32223269
    [Original] Chrome save page for MHTML format
    I. Open Chrome, enter chrome://flags in the Address bar,
    II. Find "Save Page as MHTML", click [Enable], restart Chrome, done.
    III. When this option is turned on, the save page can only be saved in MHTML format.

    2) under IE6 and IE7, refer to:
    content-type:multipart/related;
    Type= "text/html";
    boundary= "----=_PART_A47D6C30"
    x-mimeole:produced by Microsoft MimeOLE V6.00.2900.5994

    ------=_PART_A47D6C30
    content-type:text/html; charset= "Utf-8"
    Content-transfer-encoding:quoted-printable
    Content-location: =?utf-8? q?index.html?=

    =ef=bb=bf<! DOCTYPE html>


    <meta charset=3d "UTF-8" >
    <title>Document</title>
    <style type=3d "Text/css" >
    . uptip {
    width:150px;
    Background: #cdf URL (test.png) No-repeat right center;
    }
    </style>

    <script type=3d "Text/javascript" >
    alert (888);
    window.onerror =3d Function (line) {
    alert (line);
    };
    </script>
    <script type=3d "Text/javascript" src=3d "Test.js" ></script>

    <body>
    <p>1. TEXT tag:&nbsp;&nbsp;<span>2131231</span></p>
    <p>2. IMG tag:&nbsp;&nbsp;</p>
    <p class= "3D" "Uptip" >3. Css Background:&nbsp;&nbsp;<span ></span></p>
    <p>3. Test Javascript:&nbsp;&nbsp;<span id= "Testjs" ></span></p>
    </body>

    ------=_PART_A47D6C30
    Content-type:image/png
    Content-transfer-encoding:base64
    Content-location: =?utf-8? q?test.png?=

    IVBORW0KGGOAAAANSUHEUGAAABAAAAAQCAYAAAAF8/9HAAAAGXRFWHRTB2Z0D2FYZQBBZG9IZSBJ
    Bwfnzvjlywr5ccllpaaaadfjrefuenqkk71lheeyxt/zr1u4o46gilhitjmmrecwofgjhqtsaegj
    CGMYHYWLTYIG9LYHEA3NF6COHYJOOSRAIKISFY1FUUEIL+HY7T3T7XZLHTGGHE4DGXJMHD35PTVV
    MZTESGN/MWW1NX3R78DYDVWIRG4BNVLTODBBTHF6OG07KX70PMMOXKT0CNSRIVC8YND3AMMNHQVH
    Yiw5lxup27k4lgr7afkegghgwve98bje/vv9yje450nlrlh4dickucisewjsi4blvuuknrilumae
    SJOVAB4ZNGMNHIJWOIYB4BQKZ2WLT5BRREGPGJMALGEGIANYZCA5QXNWNOHUQDLGBG2C1VZWBBFN
    Ppecaqyzefmb7jaglundrtu/5/lcmgxfzfkgobtygtjcxverhshqv54detoftg4qed83kw2pgcgs
    /m649oepnxv8lg7rhvtcwu7c9kf256zlf61vao1j5spmxmb+ys00v+qzxl0om6xbpgun7lllrb3s
    3u6ef5k5g/4hx6fx0a7gb1++rx2ago7go/rxznkq97ifx/foflgt520dqoinjyakvyqilz/fn88l
    cebbyexc4sb56pts6qq++4nykcsp5q8aawdkgqwkmgyupaaaaabjru5erkjggg==

    ------=_part_a47d6c30--

  6. Reference
    1. http://www.jb51.net/article/50789.htm < Aegis encryption and decryption Tutorial (iii) PHP Aegis decryption tool >
    2, http://music.163.com/#/playlist?id=387178008&userid=5776820 < NetEase music 3D your ears >
    3, https://github.com/mangui/flashls/releases/ 4. http://blog.csdn.net/hansel/article/details/32223269 <chrome Save Web page for MHTML format >

  7. The End.

    Write Zuo Duration: <13:15:00 ~ 15:31:00> on [20161019] Ver [v0.01]

Base64 encoding is used in HTML (supports IE6, IE7, IE8)

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.