Anand
Anand

Reputation: 1325

javascript in android webview Problem?

I have problem with load javascript with html in webview below is my code it won't be able to load the view..

String strHtml="<html>"
            +"<head>"        
            +"<title>My Title</title>"    
            +"<script type=\"text/javascript\" src=\"file://android_asset/Test/Demo.js\"></script>"
            +"</script>"
            +"</head>"   
            +"<body>"     
            +"<div id=\"chartContainer\">Test Demo!</div>"          
            +"<script type=\"text/javascript\">"
            +"FusionCharts.setCurrentRenderer('javascript');"
            +"var myChart = FusionCharts.render( \"file://android_asset/Demo/Demo.swf\", \"myId\", \"280\", \"360\", \"Container\", \"file://android_asset/Data.xml\" );"
            +"</script>"
            +"</body>" 
            +"</html>";

webview.loadData(strHtml, "text/html", "utf-8");

If possible Please provide the solution with an example or if I made mistake let me know

Upvotes: 0

Views: 1320

Answers (1)

Brigham
Brigham

Reputation: 14564

You need to enable Javascript on your WebView.

webview.getSettings().setJavaScriptEnabled(true);

Upvotes: 8

Related Questions