在我的網站:如何在javascript中更改當前網址?
http://mywebsite.com/1.html
我想用
window.location.pathname
,以便獲得url的最後一部分:
1.html
,因爲我有我的號碼的所有網頁我想爲當前網址添加1,這樣當我點擊一個按鈕時,它會將我重定向到下一頁:
var url = 'http://mywebsite.com/' + window.location.pathname;
function nextImage(){
url = url + 1;
}
任何想法,爲什麼這是行不通的?
您只需在網址中加1即可。你需要增加文件名的數字部分 - #.html – Mark 2012-01-14 23:20:19