使用prototype js库匹配Href url

Href url match using prototype js library

本文关键字:Href url prototype js 使用      更新时间:2023-09-26

在我的系统中,我使用的是prototype js。

现在我想要match any href with using href.match and do want something .

尝试做某事,但它会产生问题express

Suppose: my url 

www.example.com/customer/account/login/an/aaa ? 333 = sddssdsd sasaas

想要这样:

如果任何三个ref包含customer/account/login/,那么我的条件应该是有效的。试试下面这个:

   if(accountlink.href.match(/'/customer'/account'/login'//)){
//do someting
}

但这是条件,当url:

  • www.example.com/customer/account/aaa/
  • www.example.com/aaa/account/login/an/

我不想这样。

希望就像如果href包含customer/account/login/那么它工作。

请帮帮我。

你可以使用普通的javascript来做到这一点:

var url = 'www.example.com/customer/account/login/an/aaa?333=sddssdsd,sasaas'
if (url.indexOf('customer/account/login/') > -1) {
  // Do your stuff
}

Ref。: (http://www.w3schools.com/jsref/jsref_indexof.asp)