最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Set html page padding in android WebView - Stack Overflow

programmeradmin3浏览0评论

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.

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(56)] Async pixel transfers not supported

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.

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(56)] Async pixel transfers not supported
Share Improve this question edited Nov 16, 2015 at 10:54 Vasile Doe asked Nov 16, 2015 at 10:47 Vasile DoeVasile Doe 1,7541 gold badge26 silver badges44 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

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'})();");
   }
     });
发布评论

评论列表(0)

  1. 暂无评论