javascript - JQuery IF document url = "..products.html" Then do this - Stack Overflow

How can I get the document url and pare it with an conditional branch?Pseudo Code:If document url = &qu

How can I get the document url and pare it with an conditional branch?

Pseudo Code:

If document url = "../products.html"
Then do this piece of code();

How can I get the document url and pare it with an conditional branch?

Pseudo Code:

If document url = "../products.html"
Then do this piece of code();
Share Improve this question asked Dec 3, 2010 at 8:51 TomkayTomkay 5,16021 gold badges65 silver badges94 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

If you are working with loaded html, you can try

if(window.location.pathname == "products.html"){
//do something here
}

location.pathname returns the file name or path specified by the location.

In addition, You can get the file name by

var p = window.location.pathname.split("/");
var filename = p[p.length-1];

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742295632a4417059.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信