简体   繁体   English

如何在没有哈希标签的情况下使用 jquery 哈希

[英]how to use jquery hash without hash tag

i have index.php and cpanel page that i load it by jquery into index body我有 index.php 和 cpanel 页面,我通过 jquery 将其加载到索引正文中

 if (location.hash == '#cp') { $(".body").load('cpanel/index.php'); };

i don't want to use long path folders i just need to set hash but,我不想使用长路径文件夹,我只需要设置哈希,但是,

i want to use hash without hashtag(#)我想使用没有 hashtag 的 hash(#)

example.com/#cp

i want it like facebook.com/username我想要它像facebook.com/username

example.com/cp

without any folders path .没有任何文件夹路径。

You can use server-side route methods to handle the URLs.您可以使用服务器端路由方法来处理 URL。 In case you want to use JS only you can manipulate location properties like location.pathname to manipulate URLs.如果您只想使用 JS,您可以操作 location.pathname 等location.pathname属性来操作 URL。

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

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