PROGRAMING/JAVASCRIPT

[JAVASCRIPT] Url Encode/Decode 값 확인

donghunl 2011. 6. 10. 09:35
반응형

URL Decoder/Encoder






<script type="text/javascript">
function encode() {
 var obj = document.getElementById('dencoder');
 var unencoded = obj.value;
 obj.value = encodeURIComponent(unencoded);
}
function decode() {
 var obj = document.getElementById('dencoder');
 var encoded = obj.value;
 obj.value = decodeURIComponent(encoded.replace(/\+/g,  " "));
}
</script>
</head>
<body>
<form onsubmit="return false;">
<h1>URL Decoder/Encoder</h1>
<textarea cols="80" rows="5" id="dencoder"></textarea>
<div>
<input type="button" onclick="decode()" value="Decode">
<input type="button" onclick="encode()" value="Encode">
</div>
</form>
반응형