[TIMOB-13045] iOS: WebView does not load local html files without ".html" file extension
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2013-03-21T18:28:37.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | regression |
Reporter | Tommy Leung |
Assignee | Shak Hossain |
Created | 2013-03-11T17:24:08.000+0000 |
Updated | 2017-03-22T18:08:05.000+0000 |
Description
Problem
Loading local files into webview do not work anymore. The latest TI SDk that work with this feature is 3.0.0.GA.Test case
var win = Ti.UI.createWindow();
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "testpage");
file.write("<html><body>this is the html page!!!</body></html>")
var webview = Ti.UI.createWebView({
url: file.nativePath
});
Ti.API.info(file.nativePath)
win.add(webview);
win.open();
The problem does not seem to be visible if the filename has the .html extension; it works fine without extension using 3.0.0.GA
Tested with: Titanium Studio, build: 3.0.3.201302201202 Titanium SDK, build: 3.1.0.v20130312161655 Device: iPhone5 iOS 6.0 Used *the .html extension* in the code, works fine. var win = Ti.UI.createWindow();
Downgrading as there is a workaround.
Mime-type is crucial for WebView loading. For remote URLs, mime-type is sent from server. For html/data properties, mime-type is specified in additional properties. For local URLs, file extension should match a valid mime type. This ticket could be resolved as: 1. Won't Fix, requiring valid file extension. 2. Feature Request, so support mimeType property in addition to url.
This is as a result of https://github.com/appcelerator/titanium_mobile/pull/3701. We've determined that it is important for the user to specify a file ending in .html, or use the mimeType property from the setHtml method which supports content injection.
Closing ticket as the issue will not fix and with reference to the above comments.