سؤال

The query strings in my ASP.NET MVC are formatted like this: http://mysite.com/blog/tag/my-tag, instead of http://mysite.com/blog/?tag=my-tag, I need to extract the "my-tag" bit out of the URL, how could I accomplish that with jQuery on document loaded?

هل كانت مفيدة؟

المحلول

No need to use jQuery for that:

var tag = window.location.href.split('/').pop();

نصائح أخرى

Try This:

document.location.toString().match('.*/(.*)$')[1]
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top