我有一個腳本,其結構如下圖所示:無法爲URL重定向結束與#
$(location).attr('href','<?php echo $this->here; ?>'+'#qualification');
雖然我期待重定向到myurl#qualification
不會在所有重定向。如果我刪除#qualification
,它會成功重定向到所需的位置。我怎樣才能重定向(或刷新頁面),以URL myurl#qualification
我有一個腳本,其結構如下圖所示:無法爲URL重定向結束與#
$(location).attr('href','<?php echo $this->here; ?>'+'#qualification');
雖然我期待重定向到myurl#qualification
不會在所有重定向。如果我刪除#qualification
,它會成功重定向到所需的位置。我怎樣才能重定向(或刷新頁面),以URL myurl#qualification
嘗試刪除 '+':
$(location).attr('href','<?php echo $this->here; ?>#qualification');
同樣的結果。不重定向 – Nitish
嘗試沒有jQuery的是這樣的:
window.location.href = '<?php echo $this->here; ?>#qualification';
試試這個
// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");
// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";
window.location = "http://stackoverflow.com";
在此處瞭解更多信息How to redirect to another webpage in JavaScript/jQuery?
location var包含什麼?你可以嘗試改變''標籤的散列屬性:/ – Stphane
它是一個'cakephp'語句。它輸出像'base_url/my_controller/my_action' – Nitish
...像'$(location).attr('href','<?php echo $ this-> here;?>')[0] .hash =「#資格「;' – Stphane