Tag: webview

在iOS上为内部导航引发的Xamarin.Forms.WebView.Navigating事件

假设您要阻止用户从Xamarin.Forms.WebView导航到外部页面。 public App () { var webView = new WebView { Source = new HtmlWebViewSource { Html = “Hello worldCan’t escape!” } }; webView.Navigating += WebView_Navigating; MainPage = new ContentPage { Content = webView }; } private void WebView_Navigating(object sender, WebNavigatingEventArgs e) { // we don’t want to navigate away from our page // open […]

如何在Windows 10 UWP中基于HTML内容调整Webview高度?

我目前正在使用Windows 10 UWP App并面临WebView的问题,当我的HTML内容较少时,我在javascript中获得更多高度。 我的守则如下 WebView webView = new WebView() { IsHitTestVisible = true }; string notifyJS = @” function setupBrowser(){ document.touchmove=function(){return false;};; document.onmousemove=function(){return false;}; document.onselectstart=function(){return false;}; document.ondragstart=function(){return false;} window.external.notify(‘ContentHeight:’+document.body.firstChild.offsetHeight); //window.external.notify(‘ContentHeight:’+document.getElementById(‘pageWrapper’).offsetHeight); var links = document.getElementsByTagName(‘a’); for(var i=0;i<links.length;i++) { links[i].onclick = function() { window.external.notify(this.href); return false; } } } “; string htmlContent; if (hexcolor != null) […]

在Windows Phone 8.1上检测webview中的保持事件

我目前正在开发一款主要针对Windows Phone 8.1中的win rt的网络浏览器应用。 我现在试图找出当用户在webview中按下链接或图像并显示上下文菜单时如何检测保持事件。 我该怎么做呢? 我如何在wp8.1中检测到该事件? 我知道我必须调用脚本,但是检测事件的c#是什么? 谢谢 :)

如何在webview中处理确认对话框? UWP windows 10 app C#

我正在通过c#开发uwp app(win 10) 我想把我的网站放在xaml webview元素中。 大多数function都是可行的。 但我无法处理确认对话框 例如 这是示例html和js代码 click me to confirm click me to alert function confirmBox(message) { if (confirm(message)) { alert(“yes”); } else { alert(“no”); } } 这是我的xaml代码 这是我的C#代码 webView1.ScriptNotify += webView1_ScriptNotify; webView1.NavigationCompleted += webView1_NavigationCompleted; async void webView1_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args) { await webView1.InvokeScriptAsync(“eval”, new string[] { “window.confirm = function(confirmMessage) { window.external.notify(‘typeConfirm:’ […]

如何在webview中下载文件..?

我的应用程序将打开浏览器下载文件,但我希望它在webview中下载(不要打开浏览器下载)。 我不擅长app,请尽可能给我完整的代码。 using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using Android.Webkit; using System.Net; namespace REC { [Activity(Label = “ABC”, MainLauncher = true, Icon = “@drawable/rec512”, ConfigurationChanges = Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)] public class MainActivity : Activity { private WebView mWebView; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set […]

需要在webview Win 10 UWP中获取鼠标事件

我正在创建一个win 10 UWP应用程序。 我在其中添加了一个webview,我需要右键单击并拖动webview元素的drop事件。 但现在它正在为浏览器拍摄事件。 我如何处理webview中的输入事件

ViewStartPage只能与从WebViewPage或其他ViewStartPage派生的页面一起使用

由于一些必需品,我创建了自己的自定义View Start,如下所示: public abstract class MyViewStart : System.Web.Mvc.ViewStartPage { public My.Helpers.ThemeHelper Themes { get; private set; } public MyViewStart() : base() { Themes = new Helpers.ThemeHelper(base.ViewContext) } } 需要的是在_ViewStart中我需要做一些取决于主题的布局文件查找,它的作用与问题无关。 我的意见/共享/ _ViewStart.cshtml看起来像这样(删除了无关的东西): @inherits MyNamespace.MyViewStart @{ Layout = Themes.ThemeLayout; } 因此,我们有一个自定义的ViewStart类,它派生自标准的ViewStartPage。 标准_ViewStart.cshtml是一个ViewStartPage。 新的_ViewStart.cshtml是一个MyViewStart页面,而该页面又是一个标准的ViewStartPage,因此所有内容都包含在inheritance中。 但是,当我运行应用程序时,我收到错误: ViewStartPage只能与从WebViewPage或其他ViewStartPage派生的页面一起使用 这是由我的自定义视图启动类的构造函数中的“Themes = new Helpers.ThemeHelper”行引发的。 那么,当我的自定义视图启动类是ViewStartPage的子节点时,为什么它会抛出该exception?

Xamarin表单 – 让webview回归

大家早, 我正在开发Xamarin.Forms中的一个小型跨平台webview项目。 我有webview工作,但我想添加一个工具栏,其中有一个后退和前进按钮。 我尝试了许多不同的方法,但似乎没有什么工作特别好。 我试着按照这个人发布导航工具栏来实现这个function 我将在下面附上我的代码,如果有人可以帮我解决这个或者一个很棒的解决方案! 如果此问题已经被其他用户先前回答,那么我道歉。 App.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using Xamarin.Forms; namespace DisplayWebPage { public class App : Application { public App() { // The root page of your application MainPage = new WebPage(); } protected override void OnStart() { // Handle when your app starts } protected […]

在WebView UWP中更改默认用户代理

我需要设置自定义UA并使用 httpRequestMessage.Headers.Add(“User-Agent”, “blahblah”); theWebView.NavigateWithHttpRequestMessage(httpRequestMessage); 但是,如果我点击页面上的任何链接,此UA将被删除并设置默认UA。 我发现了同样的问题WebView – 在每个请求上定义User-Agent但是它可能在1607中修复了吗?

在UWP中设置自定义WebView标头

这似乎与其他类似问题重复,但它们是旧线程,而不是Windows UWP应用程序特有的。 我无法在WebView中设置自定义标头,因此WebView中加载的URL可能对我有用。 我见过许多论坛提供的解决方案就像使用HttpClient / WebRequest一样使用标题但是在我的情况下不起作用,url使用Javascript进行重定向,在重定向之前需要很少的自定义标头来正确加载。 此外, WebView.NavigateWithHttpRequestMessage不太适合回发,我需要每个请求的标头,包括Web视图中的 javascript重定向URL。 我可以使用Renderers在Xamarin.Droid项目中设置自定义标题,但我找不到任何UWP Windows.UI.Xaml.Controls.WebView解决方案。