Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

External CSS and JS not loading

I am creating a webview in the following manner:

webviewHTML='<html><head><script type="text/javascript" src="../scripts/jquery.1.4.2.min.js"></script></head><body><span class="newsTitle">'+loadedNews[index].title+'</span><br><span class="newsDate">'+date.substr(0,date.length-15)+'<br></span><hr><span class="newsEntry">'+loadedNews[index].content+'</span></body></html>';


var webview=Titanium.UI.createWebView({html:webviewHTML});

However, the css is definitely not loading properly on android (it works on the iPhone), and neither is the jquery as when I call evalJS it also throws an error.

Any help is appreciated.

— asked August 18th 2010 by Abraham Vivas
  • android
  • css
  • external
  • js
0 Comments

2 Answers

  • Did you ever find a solution? I'm having the same problem

    — answered October 6th 2010 by Will Collins
    permalink
    1 Comment
    • Unfortunately, I was unble to figure a solution for this problem. If you ever do please let me know.

      — commented October 7th 2010 by Abraham Vivas
  • I haven't tried the technique that you're attempting, but I have had success loading local HTML files. For instance…

    var view = Ti.UI.createWebView({url:'localfile.htm'});

    Your html file, in this case 'localfile.htm', could use standard links, just as you would for a normal web page. For instance…

    <script type='text/javascript' language='javascript' src='script.js'></script>

    <link type='text/css' rel='stylesheet' media='screen' href='style.css'>

    Although the approach is slightly different, it hopefully provides you the same functionality.

    — answered October 7th 2010 by Lee Behzadi
    permalink
    1 Comment
    • I can't do this as my html code varies depending on user input, so it's not just a file.

      — commented October 27th 2010 by Abraham Vivas
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.