2012-07-31 53 views
0

我正在爲自己製作ebay模板,並且我想使用名稱錨點跳轉到頁面模板上的不同部分。但Ebay向URL添加了一些內容,因此打破了名稱錨。
由於這似乎只與Firefox有關,有人建議我需要從URL中去除「& bv = mozilla」,然後才能工作。如果有任何javascript專家可以幫助我,我會非常感激。使用javascript修剪網址

回答

1
var documentUrl = location.href; 
var newUrl = documentUrl.replace("&bv=mozilla",""); 
0

試試這個:

var url = location.protocol + '//' + location.host + location.pathname; 

或本:

var url = location.protocol + '//' + location.host + ':' + location.port + location.pathname; 

如果是在同一頁上。

否則,你可以試試這個:

var url = 'insert URL here'; 
var new_url = url.substring(0, url.indexOf('?')); 

substringindexOfwindow.location