title: Javascript - get location.pathname + location.search - not taking all parts
body: <p>I am writing js function which takes the actual <code>location.pathname + location.seach</code>, so that the user can come back to search result page if he hits <code>back</code> button. </p>
  
  <p>example url: <code>http://127.0.0.1:8000/search_for_book/?titel=&amp;autor=doniyor#</code></p>
  
  <pre><code>function select_book(bookid){
    var backurl = String(window.location.pathname+window.location.search);
    //alert(backurl); //&lt;---- this is giving the correct full path
    window.location = 'selected/?book_id=' + bookid + '&amp;back=' + backurl;
  }
  </code></pre>
  
  <p>but in the last line, function is appending only till <code>?titel=</code> and cuts off the rest. the new url is becoming this: </p>
  
  <pre><code>http://127.0.0.1:8000/search_for_book/selected/?book_id=10&amp;back=/search_for_book/?titel=
  </code></pre>
  
  <p>why is this? i need full location.pathname with full location.search. </p>
  
  <p>any ideas? </p>