使用JavaScript检查链接变量
以下面的页面为例: 使用JavaScript,如何检查窗口位置是否包含使用JavaScript检查链接变量,javascript,jquery,if-statement,contains,window.location,Javascript,Jquery,If Statement,Contains,Window.location,以下面的页面为例: 使用JavaScript,如何检查窗口位置是否包含?Page=About 这是我到目前为止的代码,但我似乎无法让它工作 $(document).ready(function(){ if ($(window.location:contains('?Page=About')").length !== 0) { alert("Currently on About page"); } else { } }); 请帮忙:) 谢谢使用.indexOf()而不是包含 if ( win
?Page=About
这是我到目前为止的代码,但我似乎无法让它工作
$(document).ready(function(){
if ($(window.location:contains('?Page=About')").length !== 0)
{
alert("Currently on About page");
}
else {
}
});
请帮忙:)
谢谢使用.indexOf()
而不是包含
if ( window.location.href.indexOf('?Page=About') > -1)
窗口。位置
包含位置对象。。href属性保存url
)“
正确吗?它不应该是”
它对我不起作用,你可以发布一个演示的链接吗?啊哈..对..检查编辑的代码..$(
在if循环中是一个输入错误谢谢!我现在看到它工作了,但是有没有办法让indexOf检查整个URL。它似乎只是检查域,这在我的情况下不是很有用。。href
给你整个URL。.在我刚才使用的小提琴中作为示例。.检查