我正在開發jQuery,我偶然發現了下一個問題:我在主頁面中添加了一個IFrame,我想從裏面重新調整它們的大小。我嘗試了一些想法,但沒有成功。如何從內部更改iframe的大小?
這裏是我的代碼:
的index.html
<html>
<head>
<title>Index</title>
</head>
<body>
<iframe id="myframe" src="frame.html" width="100px" height="100px"></frame>
</body>
</html>
frame.html
<html>
<head>
<title>IFrame</title>
<script>
document.width = 500;
document.height = 500;
</script>
</head>
<body>
<h2>My IFrame</h2>
</body>
</html>
我猜這無法從不同的域做了,對不對? – Anoyz
是的,不同的域在Chrome中失敗並顯示以下消息:未捕獲的SecurityError:阻止了一個源於「http://anotherwebsite.com」的框架訪問源自「http://mywebsite.com」的框架。協議,域和端口必須匹配。「# – Zanon
我沒有收到該錯誤。作爲一個概念驗證:http://jperelli.com.ar/covert_channel_iframe_resize/ – jperelli