tomhoppe.com

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

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);

Leave a Reply

  • Recent Posts

  • Categories

  • Archives