在我的网站上:
http://mywebsite.com/1.html
我想使用
window.location.pathname
获取URL的最后一部分:
1.html
因为我把所有的网页用数字命名,所以我想在当前URL中加1,这样当我点击一个按钮时它就会将我重定向到下一页:
var url = 'http://mywebsite.com/' + window.location.pathname;
function nextImage (){
url = url + 1;
}
有什么想法,为什么这不起作用?