You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular 5无法在IE9运行,IE11正常,报权限及SCRIPT438错误求助

Fixing Angular App Issues in IE9: Two Common Errors Resolved

Hey there, let's tackle those IE9-specific bugs you're hitting—they're super common due to IE9's limited ES5 support and wonky cross-domain handling. Here's how to fix each one:

1. "observable error: Error: Access is denied"

This is almost certainly tied to cross-origin request (CORS) handling and incorrect request headers in IE9:

  • First, strip out those extra headers you're adding to your Headers object: Access-Control-Allow-Methods and Access-Control-Allow-Origin are response headers—they belong on your server's response, not your frontend request. Including them in the request triggers IE9's security checks and throws the "Access denied" error. Your cleaned-up headers should look like this:
    const headers = new Headers({ 
      'Content-Type': 'text/xml', 
      'cache-control': 'no-cache'
    });
    
  • IE9 doesn't support standard CORS via XMLHttpRequest—it uses a proprietary XDomainRequest (XDR) object instead. Angular's default HTTP client doesn't handle XDR out of the box, so you'll need to:
    • Detect IE9 in your code (using feature detection is better than user agent sniffing)
    • Switch to using XDomainRequest for cross-domain calls when running in IE9
    • Make sure your server is configured to return valid CORS response headers (like Access-Control-Allow-Origin: *) that IE9 accepts (note: XDR has limitations, e.g., it only supports GET/POST and doesn't allow custom headers beyond certain safe ones)

2. "SCRIPT438: Object doesn't support property or method 'apply'"

This error happens because IE9 is missing critical ES5+ polyfills that Angular and RxJS rely on. Here's how to fix it:

  • Open your polyfills.ts file and make sure you've included all IE9-required polyfills:
    // IE9, IE10 and IE11 requires all of the following polyfills.
    import 'core-js/es6/symbol';
    import 'core-js/es6/object';
    import 'core-js/es6/function';
    import 'core-js/es6/parse-int';
    import 'core-js/es6/parse-float';
    import 'core-js/es6/number';
    import 'core-js/es6/math';
    import 'core-js/es6/string';
    import 'core-js/es6/date';
    import 'core-js/es6/array';
    import 'core-js/es6/regexp';
    import 'core-js/es6/map';
    import 'core-js/es6/weak-map';
    import 'core-js/es6/set';
    // Add RxJS polyfills for Observable support in IE9
    import 'rxjs-compat';
    
  • Update your tsconfig.json to target ES5 (IE9 can't handle ES6+ syntax):
    {
      "compilerOptions": {
        "target": "es5",
        // Rest of your config...
      }
    }
    
  • If you're using Angular 6+, enable ES5 browser support in your angular.json build config:
    "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        // ...other options
        "es5BrowserSupport": true
      }
    }
    
  • The "line 1, character 1" error usually points to minified/packaged code with unpolyfilled syntax, so after adding these polyfills, rebuild your app and test again.

Once you apply these fixes, your Angular app should behave consistently across IE9 and IE11.

内容的提问来源于stack exchange,提问作者Mohammed Helly

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 10:07:13