WebView未在Android 2.3上显示内容

时间:2012-06-07 09:27:49

标签: android android-webview

我创建了一个项目,用于在Android 2.3及更低版本的WebView上测试网页未显示的原因(空白页面)。必须加载的URL是: https://www.geotrackline.com/android/middleware/TabletGeoFrame.php?user_id=503&method=load

应返回显示地图的网页。关键是该应用程序在Android 3.0(在GalaxyTab中测试)及以上(在Galaxy Nexus中测试)中运行良好。

这是我在Java中的代码:

WebViewTestActivity.java:

WebView wb;
private static String MAP_URL = "https://www.geotrackline.com/android/middleware/TabletGeoFrame.php?user_id=503&method=load";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    wb = (WebView)findViewById(R.id.webView);

    WebSettings settings = wb.getSettings();

    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setBuiltInZoomControls(true);
    settings.setSupportZoom(true);
    settings.setGeolocationEnabled(true);

    wb.loadUrl(MAP_URL);
    wb.setWebChromeClient(new WebChromeClient(){

            public boolean onConsoleMessage(ConsoleMessage cm) {
                Log.e("onConsoleMessage", cm.message() + " -- From line "
                                     + cm.lineNumber() + " of "
                                     + cm.sourceId());
                return true;
            }
     });

控制台消息显示下一个:

06-07 11:15:36.480: E/onConsoleMessage(21930): Uncaught SyntaxError: Unexpected token for -- From line 573 of https://www.geotrackline.com/android/middleware/js/GeoTracking.js
06-07 11:15:36.500: E/onConsoleMessage(21930): Uncaught ReferenceError: GeoTracking is not defined -- From line 15 of https://www.geotrackline.com/android/middleware/TabletGeoFrame.php?user_id=503&method=load
06-07 11:15:36.530: E/onConsoleMessage(21930): Uncaught TypeError: Cannot call method 'sendAJAX' of undefined -- From line 27 of https://www.geotrackline.com/android/middleware/TabletGeoFrame.php?user_id=503&method=load

这是我从Android 2.3及以下网址获得的回复:

<html>
    <head>
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title> :: geotracking :: </title>
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?libraries=geometry&sensor=false"></script>
        <script language="javascript1.5" src="js/GeoTracking.js" ></script>
        <script>
            var user_id = '503';
            var postn_id = "1323014511956";
            var method="load";
            var func="";
            var map = new GeoTracking("content","","","");
        </script>
        <style>
            body { margin:0; padding:0; }
        </style>
    </head>
    <body onLoad='map.sendAJAX (method, user_id);'>
        <div id="content" style="width:100%; height:100%"></div>
    </body>
</html>

知道发生了什么?

提前致谢,对不起我的英语

0 个答案:

没有答案