2013-05-16 112 views
0

我有一个功能在jquery上处理iframe,但它给错误:访问被拒绝。 我使用IE 8 PFB代码:访问被拒绝,同时执行jquery

<!DOCTYPE html> 
<html> 
<head> 
<script type="text/javascript"> 
    function resizeIframe(iframe) { 
    iframe.height = iframe.contentWindow.document.body.scrollHeight + "px"; 
    } 
</script> 


</head> 
<body> 
<iframe src="http://www.mysite.com" id="idIframe" onload="resizeIframe(this)" ></iframe> 
</body> 
</html> 

我试着调试也,但我不能找到确切的解决办法... 任何人有任何想法?

回答

1

您不允许访问已加载到框架中的其他网站的DOM。

推测www.mysite.com不是iframe自身显示的网站。 (请注意,mysite.comwww.mysite.com是不同的网站)。

+0

那么如何获取iframe中内部网站的宽度和高度? – Aquarius24

+0

你不能。如果你可以,那么你将能够以一些相当有趣的方式侵入你的访问者的隐私(例如测试框架中页面的长度以确定他们是否登录到另一个站点(并且因此在那里有帐户)) 。 – Quentin