Condition to check if a word exists in window.location.href

I want to check if the word ["sublanguageid-all" for a specific] is present in the current address of the page with the condition "if". I tried / sublanguageid -all / g but I cannot put it in if-statement

0
source share
2 answers

Not

if(window.location.href.indexOf('sublanguageid-all') != -1) 

Work?

+6
source
 if( location.href.match("sublanguageid-all") ) { alert('present') } 
+2
source

Source: https://habr.com/ru/post/913714/


All Articles