【问题标题】:IE8 iframe onload not firingIE8 iframe onload 未触发
【发布时间】:2013-08-29 13:16:52
【问题描述】:

我从一个控制器返回以下内容,在所有当前浏览器 ff、chrome 和 IE10 中导致我的 iframe 触发它是 onload 事件:

return new ContentResult { Content = "", ContentType = "text/html", ContentEncoding = System.Text.Encoding.Unicode };

但是在 IE8 中它不起作用,我一直在假设是我的客户端代码被破坏并且没有在 iframes onload 事件上添加侦听器,但我正在使用来自 @987654321 的代码@:

    var oIFrame = document.createElement('iframe');
    oIFrame.style.display = 'none';
    if(oIFrame.attachEvent)
    {
        oIFrame.attachEvent('onload', fnIFrameCallback);
    }
    else
    {
        oIFrame.onload = fnIFrameCallback;
    }
    document.body.appendChild(oIFrame);

有谁知道 IE8 是否需要从我的控制器返回一些实际内容而不是空的Content=""

【问题讨论】:

    标签: iframe internet-explorer-8 onload


    【解决方案1】:

    此代码在 IE 8 中运行良好...

    function fnIFrameCallback(){
        alert("test iframe is now loaded.");
    }
    
    function loadLocalIframe(){
        var oIFrame = document.createElement('iframe');
        oIFrame.style.display = 'none';
        if(oIFrame.attachEvent)
        {
            oIFrame.attachEvent('onload', fnIFrameCallback);
        }
        else
        {
            oIFrame.onload = fnIFrameCallback;
        }
        document.body.appendChild(oIFrame);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-10
      • 1970-01-01
      • 2015-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-23
      相关资源
      最近更新 更多