Разделите location.href, затем включите соответствующую переменную. Так, например:
var url = document.location.href,
split = url.split("/");
/*
Split will resemble something like this:
["http:", "", "example.com", "Category", "Arts", "Other", "Sub", "Categories", ""]
So, you'll find the bit you're interested in at the 4th element in the array
*/
switch(split[4]){
case "Arts":
alert("I do say old chap");
break;
case "News":
alert("Anything interesting on?");
break;
default:
alert("I have no idea what page you're on :O!");
}
personDougschedule14.03.2013
comment
Спасибо за ваш ответ, это то, что мне было нужно. И спасибо всем ответившим ниже. В большинстве ответов используется одна и та же идея url.split. Спасибо всем.
- personYallaa; 14.03.2013