blog.darkstar.work - a simple url encoder/decoder

 a simple url encoder/decoder
 http://blog.darkstar.work

Labels

Wirtschaft (152) Pressefreiheit (131) Österreich (123) IT (98) code (62) Staatsschulden (37) EZB (27) Pensionssystem (16)

2013-01-16

a simple url encoder/decoder in javascript

<script type="text/javascript" language="javascript">
    function urlencode(s) {
        if (s == null || s.value == null || s.value == '') {
            alert("Url to encode is null or empty!");
            return ;
        } 
        var uri = encodeURIComponent(s.value)
        document.getElementById('output').value = uri;
    }              
    function urldecode(s) {        
        if (s == null || s.value == null || s.value == '') {
            alert("Url to decode is null or empty!");
            return ;
        }   
        var uri = decodeURIComponent(s.value)
        document.getElementById('output').value = uri;
    }
</script>

<form action="" id="urlform">
  <table cellspacing="1" cellpadding="1">
    <tr>
      <td>
        <input type="text" id="url" name="url" size="64" maxlength="256"
          value="http%3A%2F%2Fblog.area23.at%2F" />
      </td><td>
        <input type="button" id="deocde" name="deocde" value="deocde"
          onclick="urldecode(document.getElementById('url'))" />
      </td><td align="right">
        <input type="button" id="encode" name="encode" value="encode"
          onclick="urlencode(document.getElementById('url'))" />
      </td><td align="right">
        &nbsp;a simple url encoder/decoder
      </td>   
    </tr><tr>
      <td colspan="3">
        <input type="text" id="output" name="output" size="90" maxlength="256" readonly="readonly" />
      </td><td align="right">
        &nbsp;<a href="http://blog.area23.at">http://blog.area23.at</a>
      </td>
    </tr>   
  </table>
</form>    

Keine Kommentare:

Kommentar veröffentlichen