为什么信息卡在 IE8 中不起作用?

发布于 2024-07-15 10:53:23 字数 1473 浏览 8 评论 0原文

IE8 中发生了什么变化,使得在 javascript 中检测 InfoCard Selector 支持停止工作,除非将 IE8 置于兼容模式?

更重要的是,用于检测 InfoCard 支持是否存在的新 JavaScript 代码是什么?

以下是通过 IE7(包括在某些情况下带有插件的 FireFox)运行的脚本:

function AreCardsSupported() {
    var IEVer = -1;
    if (navigator.appName == 'Microsoft Internet Explorer') {
        if (new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})").exec(navigator.userAgent) != null) {
            IEVer = parseFloat(RegExp.$1);
        }
    }

    // Look for IE 7+. 
    if (IEVer >= 7) {
        var embed = document.createElement("object");
        embed.setAttribute("type", "application/x-informationcard");

        return "" + embed.issuerPolicy != "undefined" && embed.isInstalled;
    }

    // not IE (any version)
    if (IEVer < 0 && navigator.mimeTypes && navigator.mimeTypes.length) {
        // check to see if there is a mimeType handler. 
        x = navigator.mimeTypes['application/x-informationcard'];
        if (x && x.enabledPlugin) {
            return true;
        }

        // check for the IdentitySelector event handler is there. 
        if (document.addEventListener) {
            var event = document.createEvent("Events");
            event.initEvent("IdentitySelectorAvailable", true, true);
            top.dispatchEvent(event);

            if (top.IdentitySelectorAvailable == true) {
                return true;
            }
        }
    }

    return false;
}

What changed in IE8 that makes detecting InfoCard Selector support in javascript stop working unless IE8 is put in Compatibility Mode?

And more to the point, what is the new JavaScript code to detect the presence of InfoCard support?

Here is the script that worked up through IE7, including FireFox with a plug-in in some cases:

function AreCardsSupported() {
    var IEVer = -1;
    if (navigator.appName == 'Microsoft Internet Explorer') {
        if (new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})").exec(navigator.userAgent) != null) {
            IEVer = parseFloat(RegExp.$1);
        }
    }

    // Look for IE 7+. 
    if (IEVer >= 7) {
        var embed = document.createElement("object");
        embed.setAttribute("type", "application/x-informationcard");

        return "" + embed.issuerPolicy != "undefined" && embed.isInstalled;
    }

    // not IE (any version)
    if (IEVer < 0 && navigator.mimeTypes && navigator.mimeTypes.length) {
        // check to see if there is a mimeType handler. 
        x = navigator.mimeTypes['application/x-informationcard'];
        if (x && x.enabledPlugin) {
            return true;
        }

        // check for the IdentitySelector event handler is there. 
        if (document.addEventListener) {
            var event = document.createEvent("Events");
            event.initEvent("IdentitySelectorAvailable", true, true);
            top.dispatchEvent(event);

            if (top.IdentitySelectorAvailable == true) {
                return true;
            }
        }
    }

    return false;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

把回忆走一遍 2024-07-22 10:53:23

我从 IE8 团队得到了带外答案:

更改

embed.setAttribute("type", "application/x-informationcard");

embed.type = "application/x-informationcard";

I got an answer out of band from the IE8 team:

Change

embed.setAttribute("type", "application/x-informationcard");

to

embed.type = "application/x-informationcard";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文