URL编码和解码
<!-- run -->
<img src="https://readme-typing-svg.herokuapp.com/?lines=实用在线工具;URLEncode与URLDecode;¢er=true&size=27">
<div>
<h3>URL编码与解码</h3>
<textarea name="origin-text" id="origin-text" cols="30" rows="10" placeholder="待编码URL"></textarea>
<div style="display: flex;">
<button id="encode-btn">编码🔽</button>
<button id="decode-btn">解码🔼</button>
</div>
<textarea name="encode-text" id="encode-text" cols="30" rows="10" placeholder="已编码URL"></textarea>
<script>
window.onload = function() {
var encodeBtn = document.getElementById('encode-btn')
var decodeBtn = document.getElementById('decode-btn')
encodeBtn.onclick = function() {
var originText = document.getElementById('origin-text')
var encodeText = document.getElementById('encode-text')
encodeText.value = encodeURI(originText.value)
}
decodeBtn.onclick = function() {
var originText = document.getElementById('origin-text')
var encodeText = document.getElementById('encode-text')
originText.value = decodeURI(encodeText.value)
}
}
</script>
</div>
未经作者授权,禁止转载
本文来自博客园,作者:CoderWGB,转载请注明原文链接:https://www.cnblogs.com/wgb1234/p/15885876.html
THE END