This is the first thing that comes to my mind: http://jsfiddle.net/matias/hhcKn/
just a sample code!
HTML:
<div id="body"></div>
JS:
var $iframe = $("<iframe></iframe>").appendTo("#body"); var iframe = $iframe[0]; var doc = iframe.document; //test this var content = "<h1>Hello world</h1><br><p>more content!</p>"; //and then this //var content = "<h1>Hello world</h1><br><br><br><br><br><p>more content!</p>"; if(iframe.contentDocument){ doc = iframe.contentDocument; } else if(iframe.contentWindow){ doc = iframe.contentWindow.document; } doc.open(); doc.writeln(content); doc.close(); //this is the part that might interest you var div_height = $("#body").height(); var iframe_height = $("iframe").contents().height(); if(iframe_height > div_height) alert("scrollbars present");
CSS
body{ border: 1px solid red; } iframe{ border: none; }
source share