0

我正在编写采用实际的 js 函数location.pathname + location.seach,以便用户在点击back按钮时可以返回搜索结果页面。

示例网址:http://127.0.0.1:8000/search_for_book/?titel=&autor=doniyor#

function select_book(bookid){
  var backurl = String(window.location.pathname+window.location.search);
  //alert(backurl); //<---- this is giving the correct full path
  window.location = 'selected/?book_id=' + bookid + '&back=' + backurl;
}

但在最后一行,函数只追加直到?titel=并切断其余部分。新的网址变成了这样:

http://127.0.0.1:8000/search_for_book/selected/?book_id=10&back=/search_for_book/?titel=

为什么是这样?我需要完整的 location.pathname 和完整的 location.search。

有任何想法吗?

4

1 回答 1

1
于 2013-11-10T12:41:42.713 回答