简体   繁体   English

如果语句什么都不做 javascript

[英]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语句

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"?你怎么能说“如果肯定什么都不做,否则加载这个 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';
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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