i have this:
google.setOnLoadCallback(googlata); //googlata() is a function to create a google cse
google.load('search', '1');
I want to run the top code only if the page opened is
www.example.com/example
i tried with this:
var paginaricerca= self.location.href;
var Searchpage= paginaricerca.indexOf('example')+7;
var urlpage= paginaricerca.slice(0,Searchpage);
if(urlpage=='www.example.com/example'){
google.setOnLoadCallback(googlata);
google.load('search', '1');
}
but doesn't work....
is there an another way ?
thanks a lot !!! :)
location.href gives you the current url, not sure what you are trying to do with the slicing but you should be able to compare it to a string of the url you want to check