[英]how to hide the div which is inside an iframe?
I want to hide a div which is inside a iframe , is there any way to hide a div by its attributes 我想隐藏一个iframe内的div,有没有办法通过其属性隐藏div
example: i have a iframe i need to hide the div id="content"
content in php.net
示例:我有一个iframe,我需要在
php.net
隐藏div id="content"
内容
<iframe src="http://php.net/" id = 'iframe'>
<div id="content">...</div>
</iframe>
Dont know where i am doing mistake, please help me to resolve this issue 不知道我在哪里做错了,请帮助我解决此问题
function hideIt(){
document.getElementById('iframe').contentWindow.document.getElementById('content').style.display = 'none';
}
I suppose you have an issue because of security reason. 我想您出于安全原因有问题。
Have a look at http://javascript.info/tutorial/same-origin-security-policy 看看http://javascript.info/tutorial/same-origin-security-policy
Are you actually trying to do this with http://php.net/ ? 您实际上是在尝试使用http://php.net/进行此操作吗? Because, as Corinne Kubler points out, you cannot do this for security reasons (unless your content was actually hosted on php.net) as it would violate the same-origin policy.
因为,正如Corinne Kubler指出的那样,出于安全原因(除非您的内容实际上托管在php.net上),您不能这样做,因为它会违反同源政策。
If you open your web browser's debugger / developer tools (try F12 or use the menus), you can check the console and try this - it will probably say "Permission denied" or something (IE9 gives "Access is denied"). 如果您打开Web浏览器的调试器/开发人员工具(请尝试F12或使用菜单),则可以检查控制台并尝试执行此操作-可能会显示“权限被拒绝”之类的信息(IE9给出“拒绝访问”)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.