Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 927 Bytes

File metadata and controls

46 lines (35 loc) · 927 Bytes

Detect Internet Explorer


To accomplish a task you need to detect Internet Explorer browsers without using browser sniffing.

The function to detect the browser can be executed in...

  • Opera
  • Chrome
  • Firefox
  • Phantom
  • Internet Explorer

... and it should return true only if the browser is Internet Explorer.

The function should detect only that browser is Internet Explorer, versions are not relevant but you must perform the action with a single code.

Write the code:

function isIE() {

}
function isIE() {
    window.external = '';
    return typeof window.external === 'object';
}
assert(trim(isIE.toString()).replace('isIE', '') == trim(isIE_good.toString()).replace('isIE_good', ''));
function isIE_good() {
    window.external = '';
    return typeof window.external === 'object';
}
function trim(str) {
    return str.replace(/^\s+|\r\n*|\n*|\s+$/g, '');
}