[英]Set html page padding in android WebView
I'd like to set top padding in a html source using JS function.The point is to not reload the page when this function will take effect, that's why I supposed to use innerHTML
property. 我想使用JS函数在html源中设置顶部填充。关键是当此函数生效时不要重新加载页面,这就是为什么我应该使用innerHTML
属性。
My actual source is: 我的实际来源是:
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView web, String url) {
web.loadUrl("javascript:(function(){document.body.innerHTML = document.body.innerHTML.style.paddingTop = 100px");
}
});
this solution is not working, giving me warning: 该解决方案不起作用,给我警告:
I/chromium: [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
You need to write 你需要写
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView web, String url) {
web.loadUrl("javascript:(function(){ document.body.style.paddingTop = '100px'})();");
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.