admin管理员组文章数量:1357294
I want to test if a word ["sublanguageid-all" to be specific] is present in the current address of the page using an 'if' condition. I've tried /sublanguageid-all/g, but I'm not able to put it in an if-statement
I want to test if a word ["sublanguageid-all" to be specific] is present in the current address of the page using an 'if' condition. I've tried /sublanguageid-all/g, but I'm not able to put it in an if-statement
Share Improve this question asked May 22, 2009 at 13:40 yogeshmangajyogeshmangaj3 Answers
Reset to default 6Doesn't
if(window.location.href.indexOf('sublanguageid-all') != -1)
work?
if( location.href.match("sublanguageid-all") ) {
alert('present')
}
you can simply try the includes(). Kindly refer following code.
if(window.location.href.includes('sublanguageid-all')) {
// your code while it exists in the URL
}
本文标签: javascriptCondition to test if a word exists in windowlocationhrefStack Overflow
版权声明:本文标题:javascript - Condition to test if a word exists in window.location.href - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744075854a2586733.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论