Inconsistent scroll width for iframe in FF / IE

I have an iframe on my page whose contents are changed by clicking links in the main part of the page. I am trying to resize the iframe to fit the content, for example:

frame.contentDocument.body.scrollWidth

This works fine in Chrome, but in Firefox and IE I get an iframe, which is compressed every time a new link is clicked. FF seems to subtract 20-37 pixels each click.

I have Googled and Stack Overflow search. Some suggestions that I found related to displaying and overflowing CSS properties. I made changes to CSS, but that didn't help. I also tried the beta version of FF 21 in the hope that it was fixed there, but it is not.

+5
source share
2

jsFiddle, , , , , . , , . , iframe , scrollWidth, reset iframe 0px, scrollWidth. , scrollWidth , , ( scrollWidth width iframe).

jsFiddle. . :

var frame = document.getElementById("frame");

frame.onload = function () {
  $("#frame").css("width", '0px');
  $("#frame").css("width", frame.contentDocument.documentElement.scrollWidth + 'px');
}

jQuery, , , , , width iframe, frame.contentDocument.documentElement.scrollWidth of frame.contentDocument.body.scrollWidth. , html body, html body , iframe margins paddings.

Edit:

, , , Firefox, Chrome. , width iframe 0px scrollWidth, , overflow: visible iframe. . ( Chrome, Firefox, scrolling yes, overflow visible).

, reset width iframe, scrollWidth width . , width scrollWidth, , , , width iframe width .

: width iframe 0px ( - minimum width ) scrollWidth iframe, .

+2

contentWindow contentDocument.

0

All Articles