简体   繁体   English

此javascript将iFrame加载到页面上。 它不会在IE中加载...

[英]This javascript gets the iFrame to load on a page. It won't load in IE…

Here's the js we're using to call the iframe. 这是我们用来调用iframe的js。 In IE, it will either time out or get a " Internet Explorer cannot load the page" message. 在IE中,它将超时或收到“ Internet Explorer无法加载页面”消息。 It works fine in Chrome and Firefox. 它可以在Chrome和Firefox中正常运行。 Any insights at all would be greatly appreciated... 任何见解将不胜感激...

(function () {
    function f(i) {
        if (i.origin !== e + "" + n) {
            return
        }
        if (i.data === "destroy_bookmarklet") {
            var s = document.getElementById(g);
            if (s) {
                document.body.removeChild(s);
                s = null
            }
        }
    }
    var e = "http://",
        n = "URL GOES HERE",
        g = "ID_div",
        r = "ID_content_iframe",
        i = document.getElementById(r);
    if (i) {
        return
    }
    var d = document.createElement("div"),
        s = e + "" + n + "/post/create?response_type=embed",
        o = document.createElement("iframe");
    d.id = g;
    d.style.position = "absolute";
    d.style.top = "0";
    d.style.left = "0";
    d.style.height = "100%";
    d.style.width = "100%";
    d.style.zIndex = "16777270";
    o.id = r;
    o.src = s + "&link=" + encodeURIComponent(window.location.href) + "&title=" + encodeURIComponent(document.title) + "&description=" + encodeURIComponent("" + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text));
    o.style.height = "600px";
    o.style.width = "650px";
    o.style.border = "10px solid #333333";
    o.style.marginTop = "100px";
    o.style.marginLeft = "auto";
    o.style.marginRight = "auto";
    o.style.display = "block";
    o.style.background = "#ffffff";
    o.style.overflowY = 'scroll';
    o.style.overflowX = 'hidden';
    document.body.appendChild(d);
    d.appendChild(o);
    var u = window.addEventListener ? "addEventListener" : "attachEvent";
    var a = u == "attachEvent" ? "onmessage" : "message";
    window[u](a, f, false)
})();
if (el.addEventListener){
  el.addEventListener('your function', yourtext, false); //this is for IE 9 to above
} else if (el.attachEvent){
  el.attachEvent('your function', yourtext);//this is for IE 9 to lower
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM