2011-04-19 61 views
1

當我這樣做window.loaction我得到剝出管理員出來的url

pathname: "/shopper/admin/index.php" 

我真的需要

pathname: "/shopper/index.php" 

監守當我這樣做jQuery的負載,我需要管理員出來的網址

$('.replace').load('index.php?route=module/cart/ajax_sub?category_id=12'); 
+0

你不能只使用絕對網址嗎? '$(」取代。 ')負載('/購物者/ index.php的路線=模塊/購物車/ ajax_sub CATEGORY_ID = 12' ?);' – 2011-04-19 21:24:21

回答

5
var my_location = window.location.pathname.replace('admin/', ''); 

編輯

2

你可以用簡單的做替換:

pathname = "/shopper/admin/index.php" 
pathname = pathname.replace('/admin', ''); // replace with nothing 
// would be: "/shopper/index.php" 
2

可以使用替換功能刪除路徑的部分:

var part = '/admin'; 
window.location.replace(part, ''); 
2

嘗試以下方法從剝離「/ admin」的網址

pathname: "/shopper/admin/index.php".replace("\/admin","") 

Demo here