网页编码和解码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>Document</title>
</head>
<body>
<script>
    var  url="http://www.baidu.com";
    console.log(encodeURIComponent(url));  //网址编码,encodeURIComponent()

    var url2="http%3A%2F%2Fwww.baidu.com";
    console.log(decodeURIComponent(url2));//网址解码,decodeURIComponent()


</script>
</body>
</html>

  

原文地址:https://www.cnblogs.com/shanlu0000/p/11228691.html