After upgrading to 3.0.2 from 3.0.0 I noticed my Android webview HTML content (which I set dynamically by setting the WebView.html
property) was no longer loading my local CSS or javascript files which I had been referring to via these types of tags:
<link rel='stylesheet' type='text/css' href='css/local.css'/>and
<script type='text/javascript' src='localjs/local.js'></script>The CSS and Javascript files are located in the corresponding subdirectories under my project's
Resources
directory.
Even though the documentation for Titanium 3.0 currently states that you can assume content is relative to your project's Resources
directory, apparently 3.0.2 introduce an incompatible change for Android. You now need to use the WebView.setHTML()
function and specify the baseURL
property as below:
var html = "<html><head><link rel='stylesheet' type='text/css' href='css/local.css'/><script type='text/javascript' src='localjs/local.js'></script>"; var webview = Ti.UI.createWebView(); webview.setHtml(html, {baseURL: 'file:///android_asset/Resources/'});See the related JIRA tickets: TIMOB-12749 and TIMOB-9593