Hi im using Xamarin forms webview and i had a specific url which is developed by my company when ever im loading the url the webview is returning empty screen can someone help me with this?
First of all the URLs must be fully formed with the protocol specified (i.e. it must have "http://" or "https://" prepended to it).
var browser = new WebView
{
Source = "http://xamarin.com"
};
Check your webview layout. Maybe is not have a good position in xaml.
For ios check NSAppTransportSecurity if the url is not https.
If you want open the browser tab inside your app check this
https://askxammy.com/customizing-browser-appearance-in-xamarin-forms/
Related
First, this is for Swift 3.
I am creating a container app that simply serves a website.
The problem is that everything comes back fine and works, but the images are not showing. When debugging, it looks like the problem is that the webview isn't accepting images from an asp app site that uses a relative path to hit a .net api endpoint within the app. The image is served with the following tag:
<img src="api/Answers/Image/1006" class="panel-image" alt="">
All other functionality and data is coming back fine. The website works perfectly fine on all standard web browsers including safari. Any ideas on how to fix this.
You would think the webview would understand how to handle a relative url for an img tag... Adding protocol and host of the path to the api should solve your problem though.
If you are injecting the HTML, try something along the lines of this:
'<img src='window.location.protocol + '//' + window.location.host + '"/api/Answers/Image/1006" class="panel-image" alt="">'
Or... if you are setting it via id:
var img = document.getElementById("ImageId");
img.src = window.location.protocol + '//' + window.location.host + '/api/Answers/Image/1006';
Allen's answer was insightful on another nature of setting up a source, but I found that the back end developer for the site accidentally set the image api to require authentication. The odd thing is that this authentication didn't trigger on any device other than the ipad app. Even the browser didn't request authentication. Removing authentication on the image api fixed the problem.
Hi I wanted to load up a webview on android. And when a link is clicked in this webview to override the loading and have the link load in another webview. So I can display the first webview without having to reload the page.
You could do the following:
set a custom webview client on your webview
webView.SetWebViewClient(new MyWebviewClient(this));
In your webview client override ShouldInterceptRequest
In ShouldInterceptRequest method use the url parameter to create/show a new webview and then just return the current displayed data to prevent loading a new webview.
How to cache a webpage locally on an Android phone with app made by App Inventor? I'm actually making a web browser app for Android and I want it load my website without internet! Please help!!!
Dowload the HTML content of the page and then display it .
WebView mWebView = null;
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("yourhtmlfilepath");
dont forget to add file:/// before path
I have successfully embedded CefSharp in win form application using VS-2008 i am loading a jQueryMobile based webpage in webView which uses #id based ajax calls. which are not working in webView.
Is there any way to disable the security so i can load local files in the webview ?
got the answer by my self just needed a single line to do it
_browserSettings.FileAccessFromFileUrlsAllowed = true;
I'm building an app with a web browser control, which contains a mobile platform-customized page. The background image on that page should automatically fit to the window. And it does when visiting the URL in the ordinary browser. But when showing the page in the web browser control it doesn't fit the web browser window.
The web browser control matches the screen size. Scripts i set to allowed on the control. The WebView for android shows the page correctly.
I App.xaml.cs of your App you have to comment
//Application.Current.Host.Settings.EnableFrameRateCounter = true
//Application.Current.Host.Settings.EnableRedrawRegions = true
//Application.Current.Host.Settings.EnableCacheVisualization = true
And you will find this in public App().