Hi everybody, ?
want to write a funktion that tells my script which page of the website is actually displayed to the user. I decided to use a string search to search keywords in the page title. But to do the searching you have to use regular expressions as search parameters, and that don’t worked out quite well on my site. I only got back not founds from my searches. I think i’m doing something wrong with the regular expression… may be! ?
Here’s the script:
[CODE]
function checkSiteNameTest () {
var found = new Boolean(false);
var searchString = ‘/Test/’;
if (document.title.search(searchString) != -1) found = true;
alert(‘searchString= ‘+searchString+’, title= ‘+document.title+’, document.title.search= ‘+document.title.search(searchString)+’, found= ‘+found);
}
This is the output of the alerts:
searchString= /Test/, title= Search Test , document.title.search=-1, found=false
Greets
Jens