New to js here. Basically I am trying to detect the existence of a string in the present page's url with this:
var url = window.location;
var param = /\?provider=/i;
if (url.search(param) != -1) {
alert('it does exist');
} else
alert('it does not exist');
It works when I manually define the url variable like so
var url = 'http://google.com?provider='
but when I try to grab it dynamically like in the above script it doesn't work, is there any way to make it work?