首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何关闭wkwebview中的弹出窗口(xamarin c#)

如何关闭wkwebview中的弹出窗口(xamarin c#)
EN

Stack Overflow用户
提问于 2022-03-14 16:06:40
回答 1查看 123关注 0票数 0

我在wkwebview中创建了新的弹出窗口(onclick=“popopen(this.href)”)

代码语言:javascript
复制
 public override WKWebView CreateWebView(WKWebView webView, WKWebViewConfiguration configuration, WKNavigationAction navigationAction, WKWindowFeatures windowFeatures)
        {if (navigationAction.TargetFrame == null)
            {WKPreferences wkPreferences = new WKPreferences() { JavaScriptCanOpenWindowsAutomatically = true, JavaScriptEnabled = true };
                wkPreferences.SetValueForKey(NSObject.FromObject(true), (NSString)"allowFileAccessFromFileURLs");
                WKWebViewConfiguration wkConfig = new WKWebViewConfiguration();
                wkConfig.Preferences = wkPreferences;
                WKWebView webView1 = new WKWebView(new CGRect(0, 0, webView.Frame.Width, webView.Frame.Height), wkConfig);

                webView1.LoadRequest(navigationAction.Request);
                webView1.NavigationDelegate = new AllowAllDelegate();
                webView1.UIDelegate = this;
                webView1.Configuration.ProcessPool = webView.Configuration.ProcessPool;
            
                webView.Superview.AddSubview(webView1);}

以及如何关闭新的弹出窗口?(动作像href="#“onclick=”.“)

EN

回答 1

Stack Overflow用户

发布于 2022-03-15 08:00:24

webView1作为全局变量,然后在DidClose方法中删除它。

代码语言:javascript
复制
public override void DidClose(WKWebView webView)
{
     webView1.RemoveFromSuperview();
     webView1 = null;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71470814

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档