Method based on URL parameter
I have code which I would like to execute based on all the pages in the root directory of http://www.mywebsite.com/post/
What method would I use to target the post portion of the url, that way no matter what comes after 开发者_C百科it the code executes?
my code is:
var url = document.location.href;
if (url = 'http://www.mywebsite.com/post/') {
//do something
}
I figured it out and success!
Below is the solution:
var url = document.location.href;
if (url.indexOf("post") > 0) {
//do something
}
Ultimately I would like to use this url "http://www.mywebsite.com/post/" like a wildcard. How do I this?
精彩评论