Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Development

Reply
Developer
Posts: 75
Registered: ‎09-12-2012
My Device: Looking for a BB10 testing device
My Carrier: Developper

Webview and Javascript : Uncaught TypeError

Hi all, I use in my project a webview in order to show a map, the .html file is located in my assets directory.

 

I have a button to show the activity with the webview/map.

On the first click the map is freezing cause the error :

 

Uncaught TypeError: Cannot read property 'style' of undefined at MYPROJECT///android_asset/map.html:18

Uncaught TypeError: Cannot read property '15' of undefined at MYPROJECT///android_asset/map.html:6

 

Sometimes if I go back and I click again the map is working...

 

Here is my map.html : https://gist.github.com/fredoust/5136960

And I declare my webview like this in the onCreate :

 

 webView = (WebView) findViewById(R.id.WebViewMap);
      
         webView.setClickable(true);
       
         webView.getSettings().setJavaScriptEnabled(true);
         webView.getSettings().setBuiltInZoomControls(true);
         webView.getSettings().setLoadWithOverviewMode(true);
         webView.getSettings().setUseWideViewPort(true);
         webView.getSettings().setDatabaseEnabled(true);
         webView.getSettings().setDomStorageEnabled(true);
         
         WebClientClass webViewClient = new WebClientClass();
         webView.setWebViewClient(webViewClient);
         WebChromeClient webChromeClient = new WebChromeClient();
         webView.setWebChromeClient(webChromeClient);

         final myJsInterface myJavaScriptInterface
            = new myJsInterface(this);
         webView.addJavascriptInterface(myJavaScriptInterface, "AndroidFunction");
          
         webView.loadUrl("file:///android_asset/map.html");

 

 

Hope someone could help me.

Thanks for reading.

 

Fred

 

 

---------
Mobile developer freelance - QtQuick - Cascades - WP7 - Android
My works : http://fdelgado.fr
Developer
Posts: 75
Registered: ‎09-12-2012
My Device: Looking for a BB10 testing device
My Carrier: Developper

Re: Webview and Javascript : Uncaught TypeError

I just see that there is the same problem here : http://supportforums.blackberry.com/t5/Android-Runtime-Development/Google-Maps-in-webview/td-p/21733...

 

Thanks.

---------
Mobile developer freelance - QtQuick - Cascades - WP7 - Android
My works : http://fdelgado.fr