Getting the part of string from the URL as path - Javascript String Operation

Javascript examples for String Operation:String Substring

Description

Getting the part of string from the URL as path

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script type="text/javascript">
(function () {/*from  w ww. ja  v a 2  s .c  om*/
    var location = {
        href: 'http://localhost:8080/MyApp/MyScreen?userName=ccc'
    };
    var baseUrl = "http://localhost:8080/MyApp";
    var pagePath = location.href.replace(baseUrl, "");
    console.log(pagePath);
})();

      </script>  
   </body>
</html>

Related Tutorials