网页编码和解码

<!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>

  

posted @ 2019-07-22 21:49  shanlu  阅读(375)  评论(0编辑  收藏  举报