Webview 在尝试加载折线图报告数据时显示错误消息:SYNTAX_ERR:Dom 异常 12
Webview Showing error message while tried to load with Line chart report data: SYNTAX_ERR: Dom Exception 12
我已经实现了 google 图表来生成折线图报告。它在上述 ICS 设备中运行良好。但在 ICS 网络视图中加载错误消息而不是预期的折线图报告。
网页视图在什么情况下可以在网页上显示此错误
错误信息是:
SYNTAX_ERR: Dom 异常 12
我该如何解决这个错误?
ICS 中的异常上升类似于
03-30 10:02:36.490: W/webcore(6343): java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up.
03-30 10:02:36.490: W/webcore(6343): at android.webkit.WebViewCore$EventHub.removeMessages(WebViewCore.java:2453)
03-30 10:02:36.490: W/webcore(6343): at android.webkit.WebViewCore$EventHub.access400(WebViewCore.java:1197)
03-30 10:02:36.490: W/webcore(6343): at android.webkit.WebViewCore.removeMessages(WebViewCore.java:2565)
03-30 10:02:36.490: W/webcore(6343): at android.webkit.WebView.sendOurVisibleRect(WebView.java:3429)
03-30 10:02:36.490: W/webcore(6343): at android.webkit.ZoomManager.setZoomScale(ZoomManager.java:960)
03-30 10:02:36.490: W/webcore(6343): at android.webkit.ZoomManager.access00(ZoomManager.java:57)
03-30 10:02:36.490: W/webcore(6343): at android.webkit.ZoomManager$PostScale.run(ZoomManager.java:1448)
03-30 10:02:36.490: W/webcore(6343): at android.os.Handler.handleCallback(Handler.java:605)
03-30 10:02:36.490: W/webcore(6343): at android.os.Handler.dispatchMessage(Handler.java:92)
03-30 10:02:36.490: W/webcore(6343): at android.os.Looper.loop(Looper.java:137)
03-30 10:02:36.490: W/webcore(6343): at android.app.ActivityThread.main(ActivityThread.java:4507)
03-30 10:02:36.490: W/webcore(6343): at java.lang.reflect.Method.invokeNative(Native Method)
03-30 10:02:36.490: W/webcore(6343): at java.lang.reflect.Method.invoke(Method.java:511)
03-30 10:02:36.490: W/webcore(6343): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
03-30 10:02:36.490: W/webcore(6343): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
03-30 10:02:36.490: W/webcore(6343): at dalvik.system.NativeStart.main(Native Method)
请帮我找出解决办法。
编辑:示例 HTML:
<html>
<head>
<meta name="viewport" content="target-densitydpi=device-dpi"/>
<style type="text/css"></style>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("visualization", "1", {packages: ["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Intervel', 'Weekly'],
['01/23/2015 - 01/24/2015', 0.0],
['01/25/2015 - 01/31/2015', 0.0],
['02/01/2015 - 02/07/2015', 0.0],
['02/08/2015 - 02/14/2015', 0.0],
['02/15/2015 - 02/21/2015', 0.0],
['02/22/2015 - 02/24/2015', 0.0]]);
var options = {
'legend': 'top',
'pointSize': 10,
'lineWidth': 3,
series: {0: {color: '#7B9008'}},
backgroundColor: 'transparent',
vAxis: {
textStyle: {fontSize: '18'},
textColor: '#8B8585',
gridlines: {color: '#CACACA'},
baselineColor: '#CACACA'
},
hAxis: {
textStyle: {fontSize: '18'},
textColor: '#8B8585',
gridlines: {color: '#CACACA'},
baselineColor: '#CACACA'
}
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}</script>
</head>
<body style="background-color:transparent">
<div id="chart_div" style="width:100%; height:100%; text-align:left"></div>
</body>
</html>
问题是我使用 webView.loadDataWithBaseURL(null, data, "text/html", "UTF-8", null) 来加载 HTML 内容。我将其替换为 webView.loadData( data, "text/html", "UTF-8").
loadDataWithBaseURL(): 将给定的数据加载到这个 WebView 中,使用 baseUrl 作为 contentURL 的基础
这里我指定了 null 来代替 base URL。但我不明白为什么它在 ICS 以外的其他 android 版本中有效。
loadData():使用 'data' 方案 URL.
将给定数据加载到此 WebView
在我的例子中,我应该使用 loadData()。
我已经实现了 google 图表来生成折线图报告。它在上述 ICS 设备中运行良好。但在 ICS 网络视图中加载错误消息而不是预期的折线图报告。
网页视图在什么情况下可以在网页上显示此错误 错误信息是: SYNTAX_ERR: Dom 异常 12
我该如何解决这个错误?
ICS 中的异常上升类似于
03-30 10:02:36.490: W/webcore(6343): java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up.
03-30 10:02:36.490: W/webcore(6343): at android.webkit.WebViewCore$EventHub.removeMessages(WebViewCore.java:2453)
03-30 10:02:36.490: W/webcore(6343): at android.webkit.WebViewCore$EventHub.access400(WebViewCore.java:1197)
03-30 10:02:36.490: W/webcore(6343): at android.webkit.WebViewCore.removeMessages(WebViewCore.java:2565)
03-30 10:02:36.490: W/webcore(6343): at android.webkit.WebView.sendOurVisibleRect(WebView.java:3429)
03-30 10:02:36.490: W/webcore(6343): at android.webkit.ZoomManager.setZoomScale(ZoomManager.java:960)
03-30 10:02:36.490: W/webcore(6343): at android.webkit.ZoomManager.access00(ZoomManager.java:57)
03-30 10:02:36.490: W/webcore(6343): at android.webkit.ZoomManager$PostScale.run(ZoomManager.java:1448)
03-30 10:02:36.490: W/webcore(6343): at android.os.Handler.handleCallback(Handler.java:605)
03-30 10:02:36.490: W/webcore(6343): at android.os.Handler.dispatchMessage(Handler.java:92)
03-30 10:02:36.490: W/webcore(6343): at android.os.Looper.loop(Looper.java:137)
03-30 10:02:36.490: W/webcore(6343): at android.app.ActivityThread.main(ActivityThread.java:4507)
03-30 10:02:36.490: W/webcore(6343): at java.lang.reflect.Method.invokeNative(Native Method)
03-30 10:02:36.490: W/webcore(6343): at java.lang.reflect.Method.invoke(Method.java:511)
03-30 10:02:36.490: W/webcore(6343): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
03-30 10:02:36.490: W/webcore(6343): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
03-30 10:02:36.490: W/webcore(6343): at dalvik.system.NativeStart.main(Native Method)
请帮我找出解决办法。
编辑:示例 HTML:
<html>
<head>
<meta name="viewport" content="target-densitydpi=device-dpi"/>
<style type="text/css"></style>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("visualization", "1", {packages: ["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Intervel', 'Weekly'],
['01/23/2015 - 01/24/2015', 0.0],
['01/25/2015 - 01/31/2015', 0.0],
['02/01/2015 - 02/07/2015', 0.0],
['02/08/2015 - 02/14/2015', 0.0],
['02/15/2015 - 02/21/2015', 0.0],
['02/22/2015 - 02/24/2015', 0.0]]);
var options = {
'legend': 'top',
'pointSize': 10,
'lineWidth': 3,
series: {0: {color: '#7B9008'}},
backgroundColor: 'transparent',
vAxis: {
textStyle: {fontSize: '18'},
textColor: '#8B8585',
gridlines: {color: '#CACACA'},
baselineColor: '#CACACA'
},
hAxis: {
textStyle: {fontSize: '18'},
textColor: '#8B8585',
gridlines: {color: '#CACACA'},
baselineColor: '#CACACA'
}
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}</script>
</head>
<body style="background-color:transparent">
<div id="chart_div" style="width:100%; height:100%; text-align:left"></div>
</body>
</html>
问题是我使用 webView.loadDataWithBaseURL(null, data, "text/html", "UTF-8", null) 来加载 HTML 内容。我将其替换为 webView.loadData( data, "text/html", "UTF-8").
loadDataWithBaseURL(): 将给定的数据加载到这个 WebView 中,使用 baseUrl 作为 contentURL 的基础
这里我指定了 null 来代替 base URL。但我不明白为什么它在 ICS 以外的其他 android 版本中有效。
loadData():使用 'data' 方案 URL.
将给定数据加载到此 WebView在我的例子中,我应该使用 loadData()。