I had a similar issue in Chrome with an iframe embedded in the jQuery UI tab. When the first tab containing the iframe is displayed, a scroll bar appears. But when I switch to another tab and back to the tab with iframe, then the scrollbar disappears. All the solutions offered here did not help me. Here is what I did to solve the problem: First, I create tabs:
$("#mytabs").tabs();
Then I bind the function to the tabsactivate event, and I check to see if the targeting contains the iframe. If so, I call the fixChromeScrollBar () function, described below:
$("#mytabs").on("tabsactivate", function(event, ui) { if ($(event.originalEvent.target).attr("href") == "#mytab-with-iframe") { fixChromeScrollBar(); } });
And finally, here is the fixChromeScrollBar () function, which sets the iframe body overflow style attribute (as already mentioned) to either "scroll" or "automatically." I noticed that when I define only “auto” or “scroll”, then if I switch to another tab and return to the iframe, I will lose the scroll bar. The only way to support them is to alternate the two values each time an iframe appears. This is strange, but it works:
function fixChromeScrollBar() { var iFrameBody = $("#myiframe").contents().find("body"); var originalOverflow = $(iFrameBody).css("overflow"); if (originalOverflow == "visible" || originalOverflow == "auto") { $(iFrameBody).css("overflow", "scroll"); } else { $(iFrameBody).css("overflow", "auto"); } }
You may notice that this method is only called when you switch to the tab containing the iframe, so if you click several times on this tab without switching to another, this code will be executed only for the first time.
alex78160
source share