2011-04-19 2 views
1

때 내가 window.loaction 할관리자를 URL에서 제거

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

becuase jquery로드 할 때 나는 관리자가 필요합니다.

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

절대 URL을 사용할 수 없습니까? load ('/ shopper/index.php? route = module/cart/ajax_sub? category_id = 12');'$ ('. –

답변

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"을 제거하려면 다음 시도 URL을

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

Demo here

관련 문제