0

IEで奇妙な問題が発生しています。

私は持っています

tool==''ツール変数は空にすることができ、IEを幸せにする必要があるようです 。

//work in IE and other browsers..
  if(tool==null || tool==''){Alert('bang!!!');}

//doesn't work in IE but not other browsers.
  if(tool==null){Alert('bang!!!');}

何が起きてる?

4

2 に答える 2

1

これを試して:

if( !tool ){
  Alert('bang!!!');
}

ここでは、またはの場合!toolに戻ります。truetool = nulltool = ''

于 2012-09-14T20:45:49.247 に答える
0

この記事: http ://saladwithsteve.com/2008/02/javascript-undefined-vs-null.html はそれを非常によく説明しています。

使用できますif(!tool) alert('bang');

于 2012-09-14T20:49:14.863 に答える