WebView 와 js 가 호출 된 구덩이
public class MainActivity extends AppCompatActivity {
private WebView mWebView = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
showWebView();
}
private void showWebView() {
mWebView = (WebView) findViewById(R.id.mWebView);
WebSettings webSettings = mWebView.getSettings();
// android js
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("file:///android_asset/hello.html");
// , hello.html ,
// String content = "{\"content\":\"\\u003cdiv\\u003e\\u003cp\\u003e NEXON RPG 《 》 7 28 iOS/Android !\\u0026nbsp;\\u003c/p\\u003e\\u003cp\\u003e\\u003cimg src\\u003d\\\"http://qn.18touch.com/uploads/acg201607/14697849067464_water.jpg\\\" width\\u003d\\\"600\\\" alt\\u003d\\\"2\\\"/\\u003e\\u003c/p\\u003e\\u003cp\\u003e 、 “ ” RPG , 。\\u003c/p\\u003e\\u003cp\\u003e\\u003cimg src\\u003d\\\"http://qn.18touch.com/uploads/acg201606/14665057507557_water.jpg\\\" width\\u003d\\\"600\\\" alt\\u003d\\\"3\\\"/\\u003e\\u003cimg src\\u003d\\\"http://qn.18touch.com/uploads/acg201606/14665057538582_water.jpg\\\" width\\u003d\\\"600\\\" alt\\u003d\\\"4\\\"/\\u003e\\u003cimg src\\u003d\\\"http://qn.18touch.com/uploads/acg201606/14665057587465_water.jpg\\\" width\\u003d\\\"600\\\" alt\\u003d\\\"5\\\"/\\u003e\\u003cimg src\\u003d\\\"http://qn.18touch.com/uploads/acg201606/14665057613407_water.jpg\\\" width\\u003d\\\"600\\\" alt\\u003d\\\"6\\\"/\\u003e\\u003c/p\\u003e\\u003cp\\u003e , 2 。\\u003c/p\\u003e\\u003cp\\u003e\\u003cimg src\\u003d\\\"http://qn.18touch.com/uploads/acg201607/14697850097742_water.jpg\\\" width\\u003d\\\"600\\\" alt\\u003d\\\"4\\\"/\\u003e\\u003c/p\\u003e\\u003cp\\u003e :\\u003ca href\\u003d\\\"http://mobile.nexon.co.jp/fwt\\\"\\u003ehttp://mobile.nexon.co.jp/fwt\\u003c/a\\u003e\\u003c/p\\u003e\\u003cp\\u003e\\u003cbr/\\u003e\\u003c/p\\u003e\\u003c/div\\u003e\",\"title\":\" RPG 《 》 \"}
";
// mWebView.loadUrl("javascript: showHtmlcallJava2(" + content + ")");
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
// ,hello.html 。
String content = "{\"content\":\"\\u003cdiv\\u003e\\u003cp\\u003e NEXON RPG 《 》 7 28 iOS/Android !\\u0026nbsp;\\u003c/p\\u003e\\u003cp\\u003e\\u003cimg src\\u003d\\\"http://qn.18touch.com/uploads/acg201607/14697849067464_water.jpg\\\" width\\u003d\\\"600\\\" alt\\u003d\\\"2\\\"/\\u003e\\u003c/p\\u003e\\u003cp\\u003e 、 “ ” RPG , 。\\u003c/p\\u003e\\u003cp\\u003e\\u003cimg src\\u003d\\\"http://qn.18touch.com/uploads/acg201606/14665057507557_water.jpg\\\" width\\u003d\\\"600\\\" alt\\u003d\\\"3\\\"/\\u003e\\u003cimg src\\u003d\\\"http://qn.18touch.com/uploads/acg201606/14665057538582_water.jpg\\\" width\\u003d\\\"600\\\" alt\\u003d\\\"4\\\"/\\u003e\\u003cimg src\\u003d\\\"http://qn.18touch.com/uploads/acg201606/14665057587465_water.jpg\\\" width\\u003d\\\"600\\\" alt\\u003d\\\"5\\\"/\\u003e\\u003cimg src\\u003d\\\"http://qn.18touch.com/uploads/acg201606/14665057613407_water.jpg\\\" width\\u003d\\\"600\\\" alt\\u003d\\\"6\\\"/\\u003e\\u003c/p\\u003e\\u003cp\\u003e , 2 。\\u003c/p\\u003e\\u003cp\\u003e\\u003cimg src\\u003d\\\"http://qn.18touch.com/uploads/acg201607/14697850097742_water.jpg\\\" width\\u003d\\\"600\\\" alt\\u003d\\\"4\\\"/\\u003e\\u003c/p\\u003e\\u003cp\\u003e :\\u003ca href\\u003d\\\"http://mobile.nexon.co.jp/fwt\\\"\\u003ehttp://mobile.nexon.co.jp/fwt\\u003c/a\\u003e\\u003c/p\\u003e\\u003cp\\u003e\\u003cbr/\\u003e\\u003c/p\\u003e\\u003c/div\\u003e\",\"title\":\" RPG 《 》 \"}
";
mWebView.loadUrl("javascript: showHtmlcallJava2(" + content + ")");
}
});
}
}
그 중의 hello. html 는 다음 과 같다.
jsandroid_test
// android HtmlcallJava2()
function showHtmlcallJava2(json){
$(".news-content-block .title h1").html(json.title);
$(".news-content-block .news-content").html(json.content.replace(/_ueditor_page_break_tag_/g,""));
// android
window.jsObj.HtmlcallJava2(str+","+str1);
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.