title: Parse URL with Javascript
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/736513/how-do-i-parse-a-url-into-hostname-and-path-in-javascript">How do I parse a URL into hostname and path in javascript?</a>  </p>
  </blockquote>
  
  
  
  <p>I’m trying to parse the url of the page. For example the current page is location.href.</p>
  
  <p>So the main page of my blog, if I use alert(location.href); it will return “<a href="http://diaryofthedead.co.cc/" rel="nofollow noreferrer">http://diaryofthedead.co.cc/</a>” in an alert box. If I use alert(location.href); on page two of my blog, it will return “<a href="http://diaryofthedead.co.cc/page/2" rel="nofollow noreferrer">http://diaryofthedead.co.cc/page/2</a>” in an alert box. Is there any way to parse the URL to get the number at the end. Does anyone know how I could do that? Could I use wildcard or something, to do something like: location.href+”page/”+*; While * is equal to whatever follows “page/”, and then turn * into a variable?</p>