【问题标题】:accessing iframe element not working in chrome访问 iframe 元素在 chrome 中不起作用
【发布时间】:2014-12-20 03:08:17
【问题描述】:

我正在使用 iframe,此 iframe 将有一个 img 标签,因此我必须将来自父 html 页面的数据设置为 iframe。 我正在通过以下方式实现这一目标

我的 HTML 是,

<img id='im' src='data:image/jpeg;base64,/9j/4AAQSkZ.....'/>

我的脚本是,

jQuery(".edit").click(function(){
    jQuery("#editor").removeClass('disable');
    frames = window.frames;
    src = jQuery('#im').attr('src');   
    jQuery(frames[0].document.getElementById('canv')).attr("src",src);
});

上面的代码在firefox的iframe中正确地传递了图像数据并设置了目标元素,但是在chrome中目标图像没有改变..这可能是什么原因?

【问题讨论】:

    标签: javascript jquery html google-chrome iframe


    【解决方案1】:

    在 iframe 方面,Chrome 有点棘手。将 doctype 添加到 iframe 文档的顶部,它应该可以工作。

    如果这不起作用,则可能是 Chrome 安全设置阻止混合内容的问题。据我了解,Chrome 不会加载非 https 的 I 帧。

    【讨论】:

    • 您是否尝试访问其他网站的内容?
    • 也可能是 Chrome 阻止混合内容的安全功能。它不再喜欢在 iFrame 中加载 http 页面(而不是 https)作为安全风险。
    • 没有来自我的网站,它只是将点击的图像显示到新的 iframe
    • 您能否在 jsfiddle 或 CodePen 上发布更多代码,以便我们更好地了解全局?
    猜你喜欢
    • 2012-07-08
    • 2012-08-31
    • 2012-10-27
    • 2010-11-29
    • 2011-03-07
    • 2017-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多