最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to ignore uppercaselowercase when selecting pathname? JSJquery - Stack Overflow

programmeradmin1浏览0评论
if (pathname == "/" || pathname == "/default.asp")

in js using jquery library.

I want this to catch "Default.asp" as well as "DeFaULT.asp" and "default.asp"

halp.

if (pathname == "/" || pathname == "/default.asp")

in js using jquery library.

I want this to catch "Default.asp" as well as "DeFaULT.asp" and "default.asp"

halp.

Share Improve this question asked Jun 8, 2010 at 1:32 NoemiNoemi 131 silver badge3 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

Use the string.toLowerCase() method, this is base javascript, no jQuery needed:

pathname = pathname.toLowerCase();
if (pathname == "/" || pathname == "/default.asp") {
  //case in-sensitive math!
}

I believe this might work:

if (pathname == "/" || pathname.toLowerCase() == "/default.asp")

发布评论

评论列表(0)

  1. 暂无评论