检查“/"在URL上使用jQuery
Check the content after the "/" on a URL with jQuery
假设我的URL是:
http://example.com/12434/示例帖子
我想检查当前URL是否包含"/"
之后的内容,换句话说,我不想检查我是否在主页上http://example.com
jQuery可以做到这一点吗?
检查location
全局对象。它具有pathname
属性:
alert( location.pathname );
window.location.href提供页面的url。测试代码
alert(window.location.href);
URL是否包含abc.com/xyz之后的任何内容,即这里的xyz可以用以下代码进行测试;
var url= window.location.href;
if(url.split("/").length>3){
// It is not the home page. It is not xyz.com. It has something after /
}
else{
// you are on the home page.
}
相关文章:
- 动态地改变“”的URL;添加新项目”;链接使用javascript/jquery
- 使用带括号的图像URL作为jQuery的背景
- 如何使用javascript/jquery获取iframe的URL的锚点属性
- 如何使用javascript或jquery mobile从url读取和显示XML文件
- 如何使用jquery或javascript在image src中添加域url
- 检测图像URL是否已损坏JQUERY
- Decode URL Javascript/JQuery
- 使用Javascript/jQuery以编程方式将当前锚点/哈希/片段附加到任何表单操作url
- jQuery .load with variable as url
- 如何创建背景图像列表'URL,并使用jQuery在单击函数时应用它们
- 如何在javascript或jquery中比较两个url
- ajax外部url加载完成后调用jquery函数
- 在我的图库(jQuery)中使用箭头导航时,更改URL中的哈希
- 使用jQuery删除部分URL
- 在JQuery中将页面翻转转换为自定义url
- JQuery/Javascript来获取给定URL的Http Header详细信息
- 获取特定点的URL(jQuery/JavaScript)
- getJSON 正在添加 previos URL.jQuery.
- 如何从字符串获取url-jQuery或Javascript
- 没有标签在url jquery手风琴