[TIMOB-25163] WebView html property always return null on Android
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2019-07-01T17:17:20.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android |
Labels | android, webview |
Reporter | Rio Diep |
Assignee | Unknown |
Created | 2017-08-09T00:41:55.000+0000 |
Updated | 2019-07-01T17:17:20.000+0000 |
Description
When loading a local html file using webview. Html attribute always return null even the content is populated successfully on the screen.
Sample: (tested with SDK 6.1.1.GA, 6.1.2.GA)
*
index.xml*
<Alloy>
<Window id="win" modal="true">
<WebView id="webview" url="/test.html" />
</Window>
</Alloy>
*
index.js*
$.win.open();
$.webview.addEventListener('load', function(e) {
setTimeout(function() {
Ti.API.info($.webview.html);
}, 100);
});
It's linked to AC-5118 ticket as i didn't describe clearly in previous ticket therefore it was closed.
Attachments
File | Date | Size |
---|---|---|
Untitled.png | 2017-08-09T23:06:17.000+0000 | 124929 |
Untitled.png | 2017-08-09T04:25:36.000+0000 | 63358 |
Hello [~rdiep], I tested your test code with my test.html file and I could not reproduce this issue. It does not return the null value. Actually getHtml( ) method returns the value of the html property. - http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.WebView-method-getHtml Testing Environment 1. Ti SDK 6.1.1.GA, 6.1.2.GA 2. Android Emulator v6, 7 Output
Thanks
Hi [~morahman] I tested with Genymotions and it always return undefined not only for html property but also other properties. Attached is the log *bulk-bill.xml*
*bulk-bill.js*
!Untitled.png|thumbnail!
Hello [~rdiep], Use this Ti.API.info($. bulkBillView.getHtml()); Instead of Alloy.Globals.log($.bulkBillView); Thanks
Hi [~morahman] Attached is the log using Ti.API.info($.bulkBillView.getHtml()); Thank you. !Untitled.png|thumbnail!
Hi [~rdiep], I see the value from your image which returns getHtml() method. What is your expected behavior? Thanks
Hi [~morahman] As i want to get the html content and replace some of the context dynamically from .js file. However, it returns undefined so i couldn't do it. In v.5.2.2.GA and 5.5.1.GA, i'm able to obtain the html content but not on sdk v6 Thanks.
Hello [~rdiep], I tested with the Ti SDK 5.5.1.GA and 6.1.2.GA and get the same output result as like this
Thanks
Hi [~morahman] I think the function getHtml() itself is the same but the actual html property is undefined. Have you tried Ti.API.log($.bulkBillView.html) ? As you seen in my previous attachment when i tried to log the $.bulkBillView object, it shows html and other properties as undefined. Thanks
Hello! Yes, the getHtml() method return the same value as html. But the latest Ti SDK getHtml() returns the "url" property value and "html" returns html property value only. Hope this helps.
Hi [~morahman] Yeah I got it. But the "html" return undefined in my case, not the html property value. Therefore i cannot get the html content of the file. Thanks.
Hello! Since getHtml() method returns the same value to the latest Ti SDK so you can use that. I don't see any issue with that method. if you set html property to the webview like [this ](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.WebView-property-html)
Thanks
Hi Due to long content of the html file, I don't think it's a good practice to put the whole html content into the html property in xml file. Could you please try with the code below and log to see what will you get for the html property? *test.html*
*index.xml*
*index.js*
Hello! It returns undefined value so I said you before alternatively you can use getHtml() method. And I will forward it to our engineering team for the undefined value. Thanks
This works fine on 6.2.2.GA
Unable to reproduce under 8.0.2.GA.