tomhoppe.com

Racing, Web Development, Photography, and Beer...Stuff that matters.

Tuesday, July 17, 2007

Find something in a string

Here is a quick snippet that sets a variable to the location of a certain string inside another string. The example I'm using is searching for "asdf" in the URL. You can use this to tell if you are on a certain page.

var theUrl= location.href;
var is_asdf = (theUrl.indexOf("asdf") != -1);

Labels: ,

0 Comments:

Post a Comment

<< Home