Encoding a URL : escape « Development « JavaScript DHTML





Encoding a URL

  


<html>
  <head>
    <title>Encoding a URL</title>
    <script type="text/javascript">
        var a = "http://www.a.com/?p=value";
        var b = escape(a);
        
        document.write("Original URL: " + a + "<BR>Encoded URL: " + b);
        
        var c = "http%3A//www.a.com/%3Fp%3Dvalue";
        var d = unescape(c);
        
        document.write("<BR>Original URL: " + c + "<BR>Unencoded URL: " + d);    

    </script>
  </head>
  <body>

  </body>
</html>

   
    
  










Related examples in the same category