Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13662] iOS: Setting html property in web view prevents setUrl from loading page

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2015-06-01T23:15:12.000+0000
Affected Version/sRelease 3.0.2, Release 3.1.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterNeville Dastur
AssigneePedro Enrique
Created2013-04-23T12:17:43.000+0000
Updated2017-03-16T21:51:44.000+0000

Description

*Problem description* I have a webview that on start up is empty on an iOS as it acts to show detail. So I used the html property to effectively set a default blank page. It seems that setting this property stops setUrl from loading a local resource. *Steps to reproduce* 1. Run test case, with testpage.html as an additional resource 2. See that "I'm the property" displays rather than "I'm the local page" 3. Comment out the html property to see that now "I'm the local page" displays *app.js*
var win = Titanium.UI.createWindow({
	title : 'Window',
	backgroundColor : 'white',
	layout : 'vertical'
});

webView = Titanium.UI.createWebView({
	width : Ti.UI.FILL,
	height : Ti.UI.FILL,
	html : '<html><body>I\'m the property</body></html>'
	// ^^ Comment out html property to "fix" problem
});
win.add(webView);

webView.setUrl("/testpage.html");

win.open();
*testpage.html*
<html>
	<body>
		I'm the local page
	</body>
</html>

Comments

  1. Daniel Sefton 2013-04-23

    Tested and confirmed on iOS 6 simulator, Ti SDK 3.1 GA.
  2. Neville Dastur 2014-08-13

    Any news on a fix for this please?
  3. Pedro Enrique 2014-08-14

    Seems like the properties of the web view are processed after the window has opened. So the html override the URL. The workaround is to set the url after the window opens:
       var win = Titanium.UI.createWindow({
           title : 'Window',
           backgroundColor : 'white',
           layout : 'vertical'
       });
        
       webView = Titanium.UI.createWebView({
           width : Ti.UI.FILL,
           height : Ti.UI.FILL,
           html : '<html><body>I\'m the property</body></html>'
       });
       win.add(webView);
       win.open();
       
       webView.setUrl("/pedro.html");
       
  4. Pedro Enrique 2014-08-14

    PR: https://github.com/appcelerator/titanium_mobile/pull/5971/files
  5. Lee Morris 2017-03-16

    Closing ticket as the issue has been fixed.

JSON Source