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
+2
A:
if( location.href.match("sublanguageid-all") ) {
alert('present')
}
duckyflip
2009-05-22 13:44:44
The match function takes, as its only argument, a regular expression, not a string - https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/String/Match
David Dorward
2009-05-22 14:33:24
+6
A:
Doesn't
if(window.location.href.indexOf('sublanguageid-all') != -1)
work?
Jimmy Stenke
2009-05-22 13:45:45
A:
I want if the url has particular string like(w3calculator.com/info/LINUX/...) then it have tobe redirected to http://info.w3calculator.com
Math
2009-11-22 07:25:37