我想通过解码Base64提取当前URL,或者它可以正常工作而不解码它
我的编码器网址是:
www.site.com/search?cT1pZnJhbWUmb3E9aWZyYW1lJmFxcz1jaHJvbWUuLjY5aTU3ajY5aTU5ajY5aTY1bDNqNjlpNjBzMJV
<p id="lin"></p>
<script>
document.getElementById("lin").innerHTML =
"url: " + window.location.href;
</script>
必须解密
url:https://www.google.com/search?q=iframe&oq=iframe&aqs=chrome..69i57j69i59j69i65l3j69i60l3.1478248423j0j0&sourceid=chrome&ie=UTF-8
<p id="lin"></p>
<script>
document.getElementById("lin").innerHTML =
"url: " + window.location.hostname + "?" + (atob( window.location.search.split('&')[1]));
</script>
您可能考虑使用atob()
atob()
let url = "www.site.com/search?cT1pZnJhbWUmb3E9aWZyYW1lJmFxcz1jaHJvbWUuLjY5aTU3ajY5aTU5ajY5aTY1bDNqNjlpNjBzMJV";
let parts = url.split("?");
document.querySelector("p").innerHTML = parts[0] + "?" + atob(parts[1]);