Javascript examples for Browser Object Model:Window open
Split URL by forward slash / from the 2nd one to the end
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* ww w. java 2s .com*/ var url = "www.my.com/store/all-books/nove/book-name/", urlParts = url.split('/'), newUrl; urlParts.shift(); urlParts.shift(); urlParts.unshift( '' ); newUrl = urlParts.join('/'); console.log( url ); console.log( newUrl ); } </script> </head> <body> </body> </html>