2011-04-19 66 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