开发者

Jquery load outside iframe

开发者 https://www.devze.com 2023-03-28 14:41 出处:网络
I have a very strange problem, i have an iframe that is able to communicate with it\'s parent, but only in some certain ways. For an example i have this code in the iframe

I have a very strange problem, i have an iframe that is able to communicate with it's parent, but only in some certain ways. For an example i have this code in the iframe

$(document).ready(function(){
           parent.document.getElementById('target').style.display = 'none';
});

This hides a div called target in the paren开发者_运维知识库t page. Very nice. But this code wich is really what i want to do (loading page.php into the div called target) does not work even though its placed in the exact same way:

$(document).ready(function(){
           parent.document.getElementById('target').load("page.php");
});

Does anyone know why? Peace


$(document).ready(function(){
    $('#target', parent.document).load("page.php");
});

Give that a go


$(function(){
    $(parent.document).find('#target').load("page.php");
});

you should work

0

精彩评论

暂无评论...
验证码 换一张
取 消