简体   繁体   中英

If statement does nothing javascript

Okay so here's a simple question that I understood but got asked... let's say you have an if statement

if (window.location.href == 'http://' ||
    window.location.href == 'http://?pg=pgOldMainMenu' ||
    window.location.href == 'http://default.asp#') 

else {}

How can you say "if positive do nothing, else load this HTML"?

Simply like this

var href = window.location.href;

if (href == 'http://' ||
    href == 'http://?pg=pgOldMainMenu' ||
    href == 'http://default.asp#') {}   // do nothing
else {
    href = 'url you want to load';
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM