我想执行功能up();如果网址包含“邀请”。
到目前为止,我有这个:
if(window.location.pathname == "/invt/"){
alert("invt");
}
但是,这并不提醒我。有任何想法吗?
此后,由于下面的答案,我已经可以使用此功能了。
考虑:
$(document).ready(function () {
if(window.location.href.indexOf("invt") > -1) { //checks url for "invt" (all products contain this)
up();
return;
}
});
最佳答案
尝试这个:
if ( window.location.pathname.indexOf('invt') >= 0 )
{
alert("invt");
}