0

Quite easy, but there's something I miss..Nothing is working here. So, if my first button(id=simple) is checked, my body will have a onload function (resizeIframe) and put iframe.height 1200px, else if my other button is checked (codemandeur12), put iframe.height at 1700px...but nothing is working!

<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>

My CSS for no scrollbar :

    <style type="text/css">
    iframe {
    overflow:hidden;
    width:600px;
    }
    </style>

EDIT : I am on the same website / server...

user3038607
  • 411
  • 3
  • 7
  • 18

1 Answers1

0

Try changing iframe.height to iframe.style.height

Edit:

Another idea:

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";
    }
}

Using the answer from: getElementById from iframe

Community
  • 1
  • 1
  • actually, when I just do this follow : function resizeIframe(iframe) { iframe.height = "1200px"; } it's working...It looks like I really can't select the id of a radiobutton from the outside.. – user3038607 Jan 16 '14 at 16:37