cannot set property 'overflow' of null

2019-06-26 02:21发布

问题:

webView.getSettings().setJavaScriptEnabled(true);

webView loads this html code:

<html>
    <head>
        <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([
                    ['Year', 'Sales', 'Expenses'],
                    ['2004', 1000, 400],
                    ['2005', 1170, 460],
                    ['2006', 660, 1120],
                    ['2007', 1030, 540]
                ]);
                var options = {title: 'Company Performance'};
                var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
                chart.draw(data, options);
            }
        </script>
    </head>
    <body>
        <div id='chart_div' style='width: 900px; height: 500px;'></div>
    </body>
</html>

It's code from Google's example Visualization: Line Chart

webView shows text cannot set property 'overflow' of null How fix it?

回答1:

The error you are referring to is thrown from javascript, i guess (otherwise the app would crash)?

What Android OS Version are you trying to do this on? If it's 2.x, you won't get far unless your Google Chart uses a fallback renderer such as CanVg (i know highcharts uses canvg with success for that), because the WebView doesn't know svg.