我正在尝试使用 Javascript 开发一个 url 解码器,但我的代码不起作用,谁能告诉我怎么做,thx
<textarea id="input"></textarea>
<br />
<button id="yes" align="center" onclick="getInput(document.getElementById('input')">Click to transfer</button>
<p>The decoded URL:</p>
<textarea id="decode"></textarea>
<script>
function getInput(inputElement) {
var decoded = "";
if inputElement == 0 {
document.write("You didn't input anything");
} else if {
var uri = inputElement;
var uri_decode = decodeURIComponent(uri);
var uri_encode = encodeURIComponent(uri)
document.getElementById("decode").innerHTML = uri_decode;
document.getElementById("encode").innerHTML = uri_encode;
decoded = uri_decode;
}
return decoded;
}
</script>