Resizing iframes inside WebView

diannepune

New Member
I'm trying to display in a \[code\]WebView\[/code\] several html files in one html using iframesI'm using the following script in the html file in order to resize the height of iframes in the current html.\[code\]<body onload="resizeFrames()" link="#bb7722" vlink="#bb7722" alink="#bb7722" > <script type="text/javascript"> // Firefox worked fine. Internet Explorer shows scrollbar because of frameborder function resizeFrames() { var all_IFrames = document.getElementsByTagName('iframe'); i = 0; while (frame = all_IFrames.item(i++)) { resizeFrame(frame); } } function resizeFrame(f) { f.style.height = f.contentWindow.document.body.scrollHeight + "px"; } </script> <iframe width="100%" scrolling="no" frameborder=0 border=0 src="http://stackoverflow.com/questions/14043315/b.html"></iframe> <iframe width="100%" scrolling="no" frameborder=0 border=0 src="http://stackoverflow.com/questions/14043315/c.html"></iframe>\[/code\]In order the javascript to work I use the foloowing code:\[code\]WebSettings webSettings = wb.getSettings();webSettings.setJavaScriptEnabled(true);\[/code\]I load the html file like this:\[code\]webView.loadUrl("file:///android_asset/a.html");\[/code\]The problem is that the size of the resized iframes is sometimes too big and somtimes too small.
 
Back
Top