在Android webview中注入JS

时间:2014-04-21 17:01:03

标签: javascript android-webview

我尝试在Web视图中注入以下JS:

    var disqusData = { 
        id: '123456',
        username: 'hello1234',
        email: 'exampe@example.com'
    };



    loadComments("phillydotcom", "http://www.philly.com/philly/news/20140414_From_hell_to_heaven__Problem_property_to_be_razed_for_luxury_apartments.html", "From%20hell%20to%20heaven:%20Problem%20property%20razed%20for%20luxury%20apartments", "255112141" )

我使用了以下代码,但它只显示空白页

    webDisqus = (WebView) findViewById(R.id.disqus);
// set up disqus
WebSettings webSettings2 = webDisqus.getSettings();
webSettings2.setJavaScriptEnabled(true);
webSettings2.setBuiltInZoomControls(true);
webDisqus.requestFocusFromTouch();
   webDisqus.loadUrl("javascript:var disqusData = { "+
                "id: '123456',"+
                "username: 'hello1234',"+
                "email: 'example@example.com'"+
                "};"+
                "loadComments(\"phillydotcom\", \"http://www.philly.com/philly/news/20140414_From_hell_to_heaven" +
                "__Problem_property_to_be_razed_for_luxury_apartments.html\"," +
                " \"From%20hell%20to%20heaven:%20Problem%20property%20razed%20for%20luxury%20apartments\", \"255112141\" )");

0 个答案:

没有答案