【问题标题】:How to hide a parent element when click to iframe单击到 iframe 时如何隐藏父元素
【发布时间】:2015-10-05 08:44:58
【问题描述】:

为什么我在不同域中时无法将事件从 iframe 传递给父级

window.onload = function () {
    myFrame = document.getElementById('test2');
    myFrame.contentDocument.addEventListener('click', function()
    {
        $("test1").hide();
    });
};
<div id="test1" style="width:150px;height:150px;position:relative;">
    <iframe id="test2" src="http://www.w3schools.com"></iframe>
</div>

我想要这样的东西:http://jsfiddle.net/nqTnz/15/

我尝试使用不同域的相同代码但不起作用:http://jsfiddle.net/z6tco5rg/

【问题讨论】:

标签: javascript jquery html iframe cross-domain


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-09
    • 2021-11-29
    • 2012-12-03
    相关资源
    最近更新 更多