admin管理员组文章数量:1333437
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];
本文标签: javascriptJQuery IF document urlquotproductshtmlquot Then do thisStack Overflow
版权声明:本文标题:javascript - JQuery IF document url = "..products.html" Then do this - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742295632a2448666.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论