<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>Base64</title> <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css"><!-- <link rel="stylesheet" href="stylesheets/base.css"> --><style type="text/css">/*base.css代码*/body { padding: 1em;}div { padding: 0.25em; margin: 0 auto;}textarea { resize: vertical; height: 400px;}button { margin: 1em;}header { margin: 0; color: #333; text-align: center; border-bottom: 1px solid #eee;}.header h2 { font-weight: 300; color: #aaa; padding: 0; margin-top: 0;}</style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script><!-- <script src="javascripts/base64.js"></script> <script src="javascripts/event.js"></script> --><script language="JavaScript" type="text/javascript">//base64.js代码var Base64 = { decode: function (str) { return decodeURIComponent(escape(window.atob(str))); }, encode: function (str) { return window.btoa(unescape(encodeURIComponent(str))); }}</script><script language="JavaScript" type="text/javascript">//event.js.代码$(function(){ $("#decode").click(function(){ var str = $("#input").val(); $("#output").val(Base64.decode(str)); }); $("#encode").click(function(){ var str = $("#input").val(); $("#output").val(Base64.encode(str)); });}); </script></head><body><div> <h2>Base64解码器和编码器</h2></div><div class="pure-form pure-g"> <div> <textarea id="input"></textarea> <button type="button" id="decode" class="pure-button pure-button-primary">Decode</button> <button type="button" id="encode" class="pure-button pure-button-primary">Encode</button> </div> <div> <textarea id="output"></textarea> </div></div></body></html>
评论已关闭!