开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜