很简单,但我想念的东西......这里什么都没有。所以,如果我的第一个按钮(id = simple)被选中,我的身体将有一个onload函数(resizeIframe)并放入iframe.height 1200px,否则如果我的其他按钮被选中(codemandeur12),将iframe.height放在1700px ..但没有什么工作!
<script>
function resizeIframe(iframe) {
if (document.getElementById('iframe').contentWindow.document.getElementById('simple').checked) {
iframe.height = "1200px";
} else if (document.getElementById('iframe').contentWindow.document.getElementById('codemandeur12').checked) {
iframe.height = "1700px";
}
}
</script>
<iframe src="http://www.cbifinance.ca/form.php" scrolling="no" height="100%" onload="resizeIframe(this);" id="iframe">
Your browser does not support iframes.
</iframe>
我的CSS没有滚动条:
<style type="text/css">
iframe {
overflow:hidden;
width:600px;
}
</style>
编辑:我在同一个网站/服务器上......
答案 0 :(得分:0)
尝试将iframe.height
更改为iframe.style.height
修改强>
另一个想法:
var iframe = document.getElementById('iframe');
var frameDoc = iframe.contentDocument || iframe.contentWindow.document;
function resizeIframe(iframe) {
if (frameDoc.getElementById('simple').checked) {
iframe.style.height = "1200px";
} else if (frameDoc.getElementById('codemandeur12').checked) {
iframe.style.height = "1700px";
}
}
使用以下答案:getElementById from iframe