2013-06-25 117 views
1

根據我的客戶需要,重定向沒有定位標記和刷新頁面的頁面, 並根據頁面外觀更改URL。我不知道這個。 我可以使用Ajax的頁面內容。但我不知道URL更改選項沒有 頁面刷新或重定向。我怎麼能用ajax j-query來做到這一點。任何一個指導我這個issue.thanks提前沒有定位標記的網址更改和使用ajax的網址更改

樣品網址

www.samplesite.com/contact.php - >無錨標記。和頁面引用這個url需要在php上工作。

回答

0

您可以使用下面的JavaScript功能

window.location.assign('http://www.samplesite.com/contact.php'); // keeps the current page in browser history 

window.location.replace('http://www.samplesite.com/contact.php'); // replaces the current page in browser history 

window.location = 'http://www.samplesite.com/contact.php'; // the same as assign() and is backward compatible even with the oldest browsers 

jsfiddle

0

爲此,可以使用下面的函數來完成。

if(pageurl!=window.location){ 
    window.history.pushState({path:pageurl},'',pageurl); 
}