mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Merge pull request #625 from NativeScript/webview-base-url
Webview base url
This commit is contained in:
@ -150,6 +150,8 @@
|
||||
<TypeScriptCompile Include="apps\tests\ui\repeaterItems-bindingToGestures.ts" />
|
||||
<TypeScriptCompile Include="apps\tests\xml-declaration\inherited-base-page.ts" />
|
||||
<TypeScriptCompile Include="apps\tests\xml-declaration\inherited-page.ts" />
|
||||
<Content Include="apps\tests\xml-declaration\test.css" />
|
||||
<Content Include="apps\tests\xml-declaration\test.html" />
|
||||
<Content Include="apps\ui-tests-app\app.css" />
|
||||
<TypeScriptCompile Include="apps\ui-tests-app\pages\handlers.ts" />
|
||||
<TypeScriptCompile Include="apps\ui-tests-app\pages\htmlview.ts" />
|
||||
@ -965,7 +967,10 @@
|
||||
<Content Include="apps\ui-tests-app\pages\text\text-view.xml" />
|
||||
<Content Include="apps\ui-tests-app\pages\text\label.xml" />
|
||||
<Content Include="apps\ui-tests-app\pages\text\button.xml" />
|
||||
<Content Include="apps\ui-tests-app\web-view\test.css" />
|
||||
<Content Include="apps\ui-tests-app\web-view\test.html" />
|
||||
<Content Include="apps\ui-tests-app\web-view\webview.xml" />
|
||||
<Content Include="apps\ui-tests-app\web-view\webviewlocalfile.xml" />
|
||||
<Content Include="fetch\fetch.js" />
|
||||
<Content Include="css-value\reworkcss-value.js" />
|
||||
<Content Include="ui\layouts\stack-layout\package.json">
|
||||
@ -1944,7 +1949,7 @@
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
<UserProperties ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2linear-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" />
|
||||
<UserProperties ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2linear-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
3
apps/ui-tests-app/web-view/test.css
Normal file
3
apps/ui-tests-app/web-view/test.css
Normal file
@ -0,0 +1,3 @@
|
||||
body {
|
||||
background-color: green;
|
||||
}
|
11
apps/ui-tests-app/web-view/test.html
Normal file
11
apps/ui-tests-app/web-view/test.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>MyTitle</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="test.css">
|
||||
</head>
|
||||
<body>
|
||||
<span style="color:red">Test</span>
|
||||
</body>
|
||||
</html>
|
@ -2,7 +2,7 @@
|
||||
<ListView loaded="loaded">
|
||||
<ListView.itemTemplate>
|
||||
<WebView loaded="onLoaded" loadStarted="onLoadStarted" loadFinished="onLoadFinished" unloaded="onUnloaded"
|
||||
url="http://www.bbc.com/" minHeight="250" />
|
||||
src="http://www.bbc.com/" minHeight="250" />
|
||||
</ListView.itemTemplate>
|
||||
</ListView>
|
||||
</Page>
|
6
apps/ui-tests-app/web-view/webviewlocalfile.xml
Normal file
6
apps/ui-tests-app/web-view/webviewlocalfile.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<Page>
|
||||
<GridLayout>
|
||||
<WebView src="~/web-view/test.html" />
|
||||
</GridLayout>
|
||||
</Page>
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user