获取当前网页网址转换成base-64编码的字符串

chenyajun  2022-10-16 14:37:03  阅读 1118 次 评论 0 条
<!DOCTYPE html><html><body><p>Click the button to decode a base-64 encoded string.</p><button onclick="myFunction()">Try it</button><p><strong>Note:</strong> The atob() method is not supported in IE9 and earlier.</p><p id="demo"></p><script>function myFunction() {
  var str = window.location.href;//like https://www.w3schools.com/bootstrap4/tryit.asp?filename=trybs_card_header&stacked=h
  var enc = window.btoa(str);
  var dec = window.atob(enc);
  var res = "Encoded String: " + enc + "<br>" + "Decoded String: " + dec;
  document.getElementById("demo").innerHTML = res;}</script></body></html>


本文地址:http://www.chenyajun.net/index.php/post/109.html
版权声明:本文为原创文章,版权归 chenyajun 所有,欢迎分享本文,转载请保留出处!

评论已关闭!