Home >Web Front-end >JS Tutorial >A weird and shortest JS script to determine IE version_javascript skills
Use conditional comment to determine IE version. Well, someone proposed it early, but didn't read the code carefully. I happened to see it yesterday when I was looking at CSS3 PIE, and I thought it was unreliable. I saw Paul Irish mention it today, so let me recommend it. This is written on the author's blog:
// UPDATE: Now using Live NodeList idea from @jdalton
var ie = (function(){
var undef,
v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
while (
div.innerHTML = '' ,
all[0]
);
return v > 4 ? v : undef;
}());
Pay attention to this while statement. It's what I find most interesting. for the comma operator. I'm not familiar with it either, and I'm just stuck on usage like variable definition. For example:
var obj = {
a: 'b',
c: 'd',
e: 'f'
}