繁体   English   中英

从网址中删除管理员

[英]stripping out the admin out of the url

当我做window.loaction我得到

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

我真的需要

 pathname: "/shopper/index.php"

因为当我执行jquery加载时,我需要url之外的管理员

$('.replace').load('index.php?route=module/cart/ajax_sub?category_id=12');  
var my_location = window.location.pathname.replace('admin/', '');

编辑

您可以使用简单的替换操作:

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

您可以使用replace函数删除路径的一部分:

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

请尝试以下操作从网址中删除“ / admin”

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

在这里演示

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM