Angularjs没有在一些旧的浏览器上工作

时间:2015-05-12 08:53:14

标签: angularjs internet-explorer browser

Angularjs脚本无法在某些旧浏览器上运行,因此我想重定向使用这些旧浏览器的用户。如何理解角度在客户端浏览器中是否有效。

2 个答案:

答案 0 :(得分:0)

自Angular 1.3以来,对IE8及以下版本的支持被删除

  

AngularJS 1.3已经放弃了对IE8的支持。在我们的网站上阅读更多关于它   博客。 AngularJS 1.2将继续支持IE8,但核心团队   不打算花时间解决IE8或者特定问题   早。

您可以像这样访问用户代理信息

$window.navigator.userAgent;

查看此问题:How to detect browser using angular?

答案 1 :(得分:0)

我使用此脚本来检测浏览器和重定向。

    $(function() {

    var BrowserDetect = {
            init: function () {
                this.browser = this.searchString(this.dataBrowser) || "Other";
                this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "Unknown";
            },
            searchString: function (data) {
                for (var i = 0; i < data.length; i++) {
                    var dataString = data[i].string;
                    this.versionSearchString = data[i].subString;

                    if (dataString.indexOf(data[i].subString) !== -1) {
                        return data[i].identity;
                    }
                }
            },
            searchVersion: function (dataString) {
                var index = dataString.indexOf(this.versionSearchString);
                if (index === -1) {
                    return;
                }

                var rv = dataString.indexOf("rv:");
                if (this.versionSearchString === "Trident" && rv !== -1) {
                    return parseFloat(dataString.substring(rv + 3));
                } else {
                    return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
                }
            },

            dataBrowser: [
                {string: navigator.userAgent, subString: "Chrome", identity: "Chrome"},
                {string: navigator.userAgent, subString: "MSIE", identity: "Explorer"},
                {string: navigator.userAgent, subString: "Trident", identity: "Explorer"},
                {string: navigator.userAgent, subString: "Firefox", identity: "Firefox"},
                {string: navigator.userAgent, subString: "Safari", identity: "Safari"},
                {string: navigator.userAgent, subString: "Opera", identity: "Opera"}
            ]

        };

        BrowserDetect.init();

        var browser_url = urlHolder.baseUrl + "browser_update/?browser=" + BrowserDetect.browser + "&version=" +BrowserDetect.version;

        if (BrowserDetect.browser == "Chrome") {
            if (BrowserDetect.version <= "30")
                document.location.href = browser_url
        } else if (BrowserDetect.browser == "Explorer") {
            if (BrowserDetect.version <= "10")
                document.location.href = browser_url
        } else if (BrowserDetect.browser == "Firefox") {
            if (BrowserDetect.version <= "25")
                document.location.href = browser_url
        }
});