开发者

JQuery IF document url = "../products.html" Then do this

开发者 https://www.devze.com 2023-01-28 08:38 出处:网络
How can I get the document url and compare it with an conditional branch? Ps开发者_开发百科eudo Code:

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

Ps开发者_开发百科eudo Code:

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


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];
0

精彩评论

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