Titanium Community Questions & Answer Archive

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

Webview preload

Is there any way to force a webview to load before I actually display it?

Essentially what I need to do is update a hidden webview with information relayed from a current webview…

— asked April 21st 2010 by JT Jankowiak
  • preload
  • webview
0 Comments

5 Answers

  • Dan's idea of hiding the webview until the content is loaded works for me. (My client asked me to simply remove the activity indicator when the web view initially loads, and surprisingly, we don't have that ability through Ti, as far as I know.)

    Here's what worked for me:

    webview.addEventListener("beforeload", function(e)
    {
        webview.hide();
    });
    
    webview.addEventListener("load", function(e)
    {
        webview.show();
    
    
    });
    
    — answered April 8th 2011 by Peter janett
    permalink
    0 Comments
  • I don't believe there's a way to preload it, but perhaps you could use the webview's load event and keep it hidden until that event fires?

    — answered April 21st 2010 by Dan Giulvezan
    permalink
    0 Comments
  • Hmmm…I guess maybe you could load that HTML content to a string with an ajax call when your app launches, manipulate that string to contain the data you need from the current webview, then load the new webview and use it's html property instead of it's url property for what content to display.

    I've never tried it quite like this but it sounds good in my head. :)

    — answered April 21st 2010 by Dan Giulvezan
    permalink
    0 Comments
  • I do this a lot…. I load the html via XHR and then prebuild the window with the webview before open it….
    when the HTML is finished loading via XHR I put the HTML to the webview and then I open it…. which will render instantly….

    — answered April 21st 2010 by Marc Bender
    permalink
    1 Comment
    • Can you provide a little example code by any chance? I'm trying to duplicate what you mention here, and I'm getting close, but seeing how you did it would really be helpful.

      I'm also wanting to have the initial, "cached" page load when the tab gets focus again after the initial load. (I have a few tabs that are simply webviews.)

      Thanks for all your help so far on this site!

      Peter Janett

      — commented July 22nd 2010 by Peter janett
  • doing tabGroup.activeTab=3; tabGroup.activeTab=0; really quickly worked for me.

    — answered January 18th 2013 by Tanner Nelson
    permalink
    0 Comments
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.