Why does JavaScript only work after opening developer tools in IE once?

前端 未结 12 2087
予麋鹿
予麋鹿 2020-11-22 02:20

IE9 Bug - JavaScript only works after opening developer tools once.

Our site offers free pdf downloads to users, and it has a simple \"enter password to download\" f

12条回答
  •  礼貌的吻别
    2020-11-22 02:31

    If you are using AngularJS version 1.X you could use the $log service instead of using console.log directly.

    Simple service for logging. Default implementation safely writes the message into the browser's console (if present).

    https://docs.angularjs.org/api/ng/service/$log

    So if you have something similar to

    angular.module('logExample', [])
      .controller('LogController', ['$scope', function($scope) {
        console.log('Hello World!');
     }]);
    

    you can replace it with

    angular.module('logExample', [])
      .controller('LogController', ['$scope', '$log', function($scope, $log) {
        $log.log('Hello World!');
     }]);
    

    Angular 2+ does not have any built-in log service.

提交回复
热议问题