我想要显示一个包含广告的脚本。当我们加载Chrome浏览器并在设备中模拟时,它工作正常。但是在Android中不起作用
这个脚本:
<div id="ym_12345" class="ym"></div><script type="text/javascript">(function(e,t){if(t._ym===void 0){t._ym="";var m=e.createElement("script");m.type="text/javascript",m.async=!0,m.src="//static.yieldmo.com/ym.min.js",(e.getElementsByTagName("head")[0]||e.getElementsByTagName("body")[0]).appendChild(m)}else t._ym instanceof String||void 0===t._ym.chkPls||t._ym.chkPls()})(document,window);</script>
我有一个网页视图布局:
代码:
String html =
"<div id=\"ym_12345\" class=\"ym\"></div>" +
"<script type=\"text/javascript\">(function(e,t){if(t._ym===void 0){t._ym=\"\";var m=e.createElement(\"script\");" +
"m.type=\"text/javascript\",m.async=!0,m.src=\"//static.yieldmo.com/ym.min.js\",(e.getElementsByTagName(\"head\")[0]" +
"||e.getElementsByTagName(\"body\")[0]).appendChild(m)}else t._ym instanceof String||void 0===t._ym.chkPls||t._ym.chkPls()})" +
"(document,window);</script>";
wv=(WebView)findViewById(R.id.webview_ndn);
wv.getSettings().setLoadWithOverviewMode(true);
wv.getSettings().setUseWideViewPort(true);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setPluginState(PluginState.ON);
//wv.getSettings().setAllowContentAccess(true);
wv.getSettings().setSupportMultipleWindows(true);
wv.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
wv.getSettings().setDomStorageEnabled(true);
wv.setWebChromeClient(new WebChromeClient());
//wv.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null);
wv.loadData(html, "text/html", "UTF-8");