Put a URL in a HTTP request as the query string - Javascript String Operation

Javascript examples for String Operation:String URL

Description

Put a URL in a HTTP request as the query string

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head>
      <script>
   function redirect(){//from w  w  w . j a  va  2s  . com
       //url you want to encrypt
       url = "http://www.example.com";
       //url encryption with BTOA function
       base64Url = btoa(url)
//       Lets Redirect to the new url with URL encrypted
       window.location = "http://www.new Address.com?url="+base64Url
   }

      </script> 
   </head>
   <body> 
      <a href="#" onclick="redirect()">redirect</a>  
   </body>
</html>

Related Tutorials