webView.html is undefined in load event handler...

You must Login before you can answer or comment on any questions.

hi; i have a WebView instance assigned to webview thats rendered within a window.webview gets initialized with url property (points to a remote page). i also have a load event handler. in the load, i wish to examine the actual html that's the result of the GET from specified url.

when i look at webview.html it is undefined!

i cannot use httpclient or such to look at the responseText... and thought that WebView.html would be sufficient.

is this a bug ? are there other things i need to configure before i can look at the loaded html page?

please advise.

1 Answer

this works for me (using same sdk version), both the event.source.html and the webView.html (be careful with capitalization).

Capture load event:

webView.addEventListener('load', function(evt){
 
    Ti.API.info(evt.source.html);
    Ti.API.info('+++++++++++++');
    Ti.API.info(webView.html);
});

— answered 2 years ago by Javier Rayon
answer permalink
4 Comments
  • on Android? (sorry to have not mentioned my error is on Android)

    all capitalization is fine, added 'evt' as you suggested and even that is undefined.

    webView.addEventListener('load', function(evt) {
     
    ...
     
            Ti.API.info('+++++++++++++++++++++++++');
            Ti.API.info(evt.source.html);
    yields following output:
    I/TiAPI   (  568): (kroll$4: file:///android_asset/Resources/app.js) [1,11213] +++++++++++++++++++++++++
    I/TiAPI   (  568): (kroll$4: file:///android_asset/Resources/app.js) [1,11214] undefined

    — commented 2 years ago by Sheshadri Mantha

  • I have duplicated this in a sample test app and i get undefined for local and remote html files (in the load event).

    i would post the sample code here but there does not seem to be any way of doing so in this forum.

    so i created a bug report and that has the entire test project zipped up as attachment. See http://jira.appcelerator.org/browse/TC-243

    Would appreciate any testing/feedback. for example, does it work on iPhone?, BB? actual android device?

    thx community!

    — commented 2 years ago by Sheshadri Mantha

  • Hi, sorry for not answering before. My comment was based on iOs, I can confirm that this property works fine on this platform.

    — commented 2 years ago by Javier Rayon

  • Show 1 more comment

Your Answer

Think you can help? Login to answer this question!