I am trying to add more WebView space to a loaded WebView using JavaScript .
I am loading data using loadDataWithBaseUrl() from a String resource. Then, after measuring some content, I need to make the WebView larger, say, by 100 pixels. Therefore, I call the javascript function using loadDataWithBaseUrl() :
mWebView.loadUrl("javascript:addHeight()");
JavaScript function defined in the source HTML:
function addHeight() { " + var elemDiv = document.createElement('div'); elemDiv.style.cssText = 'height:100px;'; document.body.appendChild(elemDiv); }
After that, the WebView resized to fit the new content. However, the resulting height is not the original Size + 100px, but more. I do not know where the problem is. I cannot determine the size of the target, because it depends on the size of the added div , and it will always be different.
Has anyone tried this? Are you familiar with this behavior?
Hawk source share