Android Question Widget of OpenWeather.org

AlpVir

Well-Known Member
Licensed User
would like to display the following widget in an Android device using a webview.

widget.jpg


This is the right HTML code to display this same widget on a PC with Windows.
This HTML code is partially generated by B4A.
B4X:
<html>
<body>
<div id="openweathermap-widget-15"></div>
<script>window.myWidgetParam ? window.myWidgetParam : window.myWidgetParam = [];  window.myWidgetParam.push({id: 15,cityid: '3177700',appid: 'xxxxxxxxxxxxxxxxxxx',units: 'metric',containerid: 'openweathermap-widget-15',  });  (function() {var script = document.createElement('script');script.async = true;script.charset = "utf-8";script.src = "//openweathermap.org/themes/openweathermap/assets/vendor/owm/js/weather-widget-generator.js";var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(script, s);  })();</script>
<body>
</html>
With Android, however, it does not work!
Is there a chance to do it?
Thanks for the attention
 

AlpVir

Well-Known Member
Licensed User
I entered the HTML in a webview
B4X:
HT1="<div id=""openweathermap-widget-15""></div>" & CRLF
HT2="<script>window.myWidgetParam ? window.myWidgetParam : window.myWidgetParam = [];  window.myWidgetParam.push({id: 15,cityid: '3177700',appid: 'xxxxxxxxx',units: 'metric',containerid: 'openweathermap-widget-15',  });  (function() {var script = document.createElement('script');script.async = true;script.charset = ""utf-8"";script.src = ""//openweathermap.org/themes/openweathermap/assets/vendor/owm/js/weather-widget-generator.js"";var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(script, s);  })();</script>"
 HH="<html><body>" & HT1 & HT2 & "</body></html>"
 Log(HH)
 WebViewOW.LoadHtml(HH)
My app presents another widget from another weather data provider on one screen.
I would also like to include those of OpenWeather, better charts than I can do by interpreting JSON data. I could do this.
I also used WebViewExtras and I enabled Javascript
 

DonManfred

Expert
Licensed User

Peter Simpson

Expert
Licensed User
Hmm you appear to be correct @AlpVir.
When you place the generated code into a WebView absolute nothing happens, but I've tested my generated code as I have an account with OWM and the code works perfect via a browser. You can even copy and past the code into w3schools.com and the widget appears in their result/output window as expected, just not in WebView in B4A or B4J.

I really wasn't expected that, brb...
 
Last edited:

AlpVir

Well-Known Member
Licensed User
Most likely it is the Javascript code that blocks the correct execution of the widget. I believe there is nothing to be done :(:(:(
 
Top