Can't load a local html file into a .NET MAUI WebView
I've fixed this with this PR into .Net Maui. Will be in the SR2 release due in the next few weeks.
The docs suggested it worked consistently on all platforms, but it simply had never been implemented on Windows... slightly concerning.
The workaround I've posted on the PR (mentioned also by Reinaldo below) will get around this for the mean time, however you should probably remove it once SR2 is released and you update to it.
(React Native) Load local HTML file into WebView
try it:
const PolicyHTML = require('./Policy.html');
<WebView
source={PolicyHTML}
style={{flex: 1}}
/>
How to load a local html file into a NativeScript webview
In NativeScript, by default, the tilde (~
) marks the app root folder (note the App and not the Project!). So if your file is located in <project-name>/app/index.html
try setting the path with ~/index.html
.
Loading existing .html file with android WebView
ok, that was my very stupid mistake. I post the answer here just in case someone has the same problem.
The correct path for files stored in assets folder is file:///android_asset/*
(with no "s" for assets folder which i was always thinking it must have a "s").
And, mWebView.loadUrl("file:///android_asset/myfile.html");
works under all API levels.
I still not figure out why mWebView.loadUrl("file:///android_res/raw/myfile.html");
works only on API level 8. But it doesn't matter now.
Unable to display html file from local storage in webview
Finally after trying all possible plugins realized that Flutter webview as of now cannot display local html files that are heavy on css & javascript side.
The same webview can only display external urls or basic html files(minus css & js).
I switched over to native android for this.
UWP app trying to load a local html file to webview control
Hey if you have time tell me if this works:
Create an Html file in your Assets folder called MyHTMLPage, it has a build action of type content and a Copy to Output to Copy Always.
Html file:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div style="background-color: chartreuse">HELLO WORLD, from a webview</div>
</body>
</html>
On Main Page.xaml:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<WebView x:Name="MyWebView" Width="200" Height="300"></WebView>
</Grid>
On Main Page.cs:
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
Loaded += MainPage_Loaded;
}
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
string src = "ms-appx-web:///Assets/MyHTMLPage.html";
this.MyWebView.Navigate(new Uri(src));
}
}
does this work for you?
Related Topics
Difficulties with Calling an Android Ndk Function from Directly Delphi
Differences Between Constraintlayout and Relativelayout
Android Textwatcher.Aftertextchanged VS Textwatcher.Ontextchanged
How to Display Album Art Using Mediastore.Audio.Albums.Album_Art
Why Is My Button Text Forced to All Caps on Lollipop
Android Spinner:Avoid Onitemselected Calls During Initialization
End Call in Android Programmatically
Android: Force Edittext to Remove Focus
Android Appcompat 21 Elevation
Remove a Marker from a Googlemap
Building Just One Tool from Android Source (Aosp)
Android 5.0 Android:Elevation Works for View, But Not Button
Edittext with Number Keypad by Default, But Allowing Alphabetic Characters
Is This the Right Way to Clean-Up Fragment Back Stack When Leaving a Deeply Nested Stack
Why Does the Google Play Store Say My Android App Is Incompatible with My Own Device