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
1 Answer
Reset to default 7If 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条)