Luci
Luci

Reputation: 3264

How to access ids found inside iframes?

I need to access an id found inside an iframe. I have the following code:

print "<IFRAME id='preview_iframe_form' ... src=\"$server_url/index.cgi ";

Inside index.cgi, I have the following :

      print"<div id='result_div'>";
      &show_list();
      print "</div>";

I need to check the result_div height so set the height of preview_iframe_form

Upvotes: 0

Views: 106

Answers (1)

tKe
tKe

Reputation: 560

Try this:

var iframe = document.getElementById('preview_iframe_form');
var iframedoc = iframe.contentWindow ? iframe.contentWindow.document : iframe.contentDocument;
var resultEl = iframedoc.getElementById('result_div');

Upvotes: 1

Related Questions