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
}