diff --git a/CrossPlatformModules.csproj b/CrossPlatformModules.csproj index 02cbc7f68..dbe6a6c2f 100644 --- a/CrossPlatformModules.csproj +++ b/CrossPlatformModules.csproj @@ -150,6 +150,8 @@ + + @@ -965,7 +967,10 @@ + + + @@ -1944,7 +1949,7 @@ False - + \ No newline at end of file diff --git a/apps/ui-tests-app/web-view/test.css b/apps/ui-tests-app/web-view/test.css new file mode 100644 index 000000000..dde830c8f --- /dev/null +++ b/apps/ui-tests-app/web-view/test.css @@ -0,0 +1,3 @@ +body { + background-color: green; +} diff --git a/apps/ui-tests-app/web-view/test.html b/apps/ui-tests-app/web-view/test.html new file mode 100644 index 000000000..f3daf0bd7 --- /dev/null +++ b/apps/ui-tests-app/web-view/test.html @@ -0,0 +1,11 @@ + + + + MyTitle + + + + + Test + + diff --git a/apps/ui-tests-app/web-view/webview.xml b/apps/ui-tests-app/web-view/webview.xml index 7e1f5ce11..2f756ac0a 100644 --- a/apps/ui-tests-app/web-view/webview.xml +++ b/apps/ui-tests-app/web-view/webview.xml @@ -2,7 +2,7 @@ + src="http://www.bbc.com/" minHeight="250" /> \ No newline at end of file diff --git a/apps/ui-tests-app/web-view/webviewlocalfile.xml b/apps/ui-tests-app/web-view/webviewlocalfile.xml new file mode 100644 index 000000000..669a78965 --- /dev/null +++ b/apps/ui-tests-app/web-view/webviewlocalfile.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/ui/web-view/web-view.android.ts b/ui/web-view/web-view.android.ts index 13dc09095..a1830da28 100644 --- a/ui/web-view/web-view.android.ts +++ b/ui/web-view/web-view.android.ts @@ -89,8 +89,9 @@ export class WebView extends common.WebView { var file = fs.File.fromPath(src); if (file) { - file.readText().then((r) => { - this._android.loadData(r, "text/html", null); + var baseUrl = `file:///${src.substring(0, src.lastIndexOf('/') + 1)}`; + file.readText().then(r => { + this._android.loadDataWithBaseURL(baseUrl, r, "text/html", null, null); }); } } else if (src.indexOf("http://") === 0 || src.indexOf("https://") === 0) { diff --git a/ui/web-view/web-view.ios.ts b/ui/web-view/web-view.ios.ts index 053857442..e33e80414 100644 --- a/ui/web-view/web-view.ios.ts +++ b/ui/web-view/web-view.ios.ts @@ -97,8 +97,9 @@ export class WebView extends common.WebView { var file = fs.File.fromPath(src); if (file) { + var baseURL = NSURL.fileURLWithPath(NSString.stringWithString(src).stringByDeletingLastPathComponent); file.readText().then((r) => { - this._ios.loadHTMLStringBaseURL(r, null); + this._ios.loadHTMLStringBaseURL(r, baseURL); }); } } else if (src.indexOf("http://") === 0 || src.indexOf("https://") === 0) {