jquery 在 iframe 外部加载
我有一个非常奇怪的问题,我有一个 iframe 能够与其父级进行通信,但只能以某些特定方式进行。例如,我在 iframe 中有此代码,
$(document).ready(function(){
parent.document.getElementById('target').style.display = 'none';
});
这隐藏了父页面中名为 target 的 div。很不错。但是这段代码确实是我想要做的(将 page.php 加载到名为 target 的 div 中),即使它以完全相同的方式放置,也不起作用:
$(document).ready(function(){
parent.document.getElementById('target').load("page.php");
});
有人知道为什么吗? 和平
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 parent 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试一下
Give that a go
你应该工作
you should work