The document on the main page contains iframe (src = "text.html"). I wrote a script in the text.html document itself, which clears the scrolling, stretching the content to the full height of the parent screen:

parent.document.getElementById('iframe0').style.height = document.documentElement.offsetHeight + 'px'; 

Everything is fine in Mozille and Opera, but in Google Chrome, when the page is updated, this frame SUDDENLY appears scrolling. Is this a Chrome bug? Or am I missing something?

  • one
    an example on jsfiddle or jsbin make - zb '14
  • I do not understand where I should write the iframe code in jsfiddle? - Deus
  • I’ll show you now, through gist you can do it - zb '14
  • Now it will turn into an online lesson on jsfiddle)). Here, for example, the main page . How can I register a file in src, where I can create and save it, I don’t understand a damn thing. - Deus
  • I was mistaken, for some reason gsfiddle makes it possible to request gist pages only through ajax, you need to ask them why. - zb '

2 answers 2

Here is your example, the problem is not repeated. comments for some reason are disabled to the task, I am writing here.

  • It is very difficult to trace this in jsfiddle, because there the window itself is broken into 4 divas, i.e. Diva with the result is not in fact a real windows window. In addition, in your example, after the word TEST, I tried to insert text content, so after that jsfiddle showed only an empty frame, even without the word test. - Deus
  • And in general, I agree that it works and should work, but Chrome disagrees. As if updating it ceases to "notice" the script in the connected frame - Deus
  • maybe it is necessary to execute an onload script? - zb '
  • scripts are written at the end of the document, before the last body, i.e. Before the script, the document tree has already been created. - Deus
 <iframe src="..." onload="document.getElementById('content').style.height = iframe.contentWindow.document.body.offsetHeight + 60 +"px"> 

where iframe is a reference to the iframe object.

Cross-browser code.