The URLs such as below are support on my website:
(1) http://mysite.example.com/section/ - main page
(2) http://mysite.example.com/section/#page2
(3) http://mysite.example.com/section/surname-name-middlename/
(4) http://mysite.example.com/section/surname-name-middlename/#page2
(5) http://mysite.example.com/section/add
现在,我正试图在另一个地点展示我的场地。 该网址支持<条码>低浓度/代码>和<条码> 改变代码>方法,界定散草,并在变后作出反应。
I ve defined setLocation
for all pages, no problem here. 因此,上述三党网站链接如下:
(1) http://3rdpartysite.com/mypage
(2) http://3rdpartysite.com/mypage#page2
(3) http://3rdpartysite.com/mypage#surname-name-middlename
(4) http://3rdpartysite.com/mypage#surname-name-middlename,page2
(5) http://3rdpartysite.com/mypage#add
但现在,我试图执行正确的
<代码><>>条/代码>是所有网页的共同部分。
我试图在主页上做以下工作(而不是上文选择(4)):
// location here is everything after # in url: http://3rdpartysite.com/mypage#...
function onLocationChanged(location) {
if (location.indexOf( page )>-1) {
window.location.href = # +location;
} else if (location == add ) {
window.location.href = window.location.host + window.location.pathname + /add ;
} else if (location != ) {
window.location.href = window.location.host + window.location.pathname + / +location+ / ;
}
}
但它没有适当开展工作。 我的做法有什么错误?