// Check if a string has a non-whitespace character in it
var rnotwhite = /\S/;
// IE doesn't match non-breaking spaces with \s
if ( rnotwhite.test( "\xA0" ) ) {
alert('i am IE');
} else {
alert('i am not IE');
var rnotwhite = /\S/;
// IE doesn't match non-breaking spaces with \s
if ( rnotwhite.test( "\xA0" ) ) {
alert('i am IE');
} else {
alert('i am not IE');
}
同样也可以使用传统的方式 :
var isIE = /MSIE/.test( navigator.userAgent );