我在wkwebview中创建了新的弹出窗口(onclick=“popopen(this.href)”)
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=”.“)
发布于 2022-03-15 08:00:24
将webView1作为全局变量,然后在DidClose方法中删除它。
public override void DidClose(WKWebView webView)
{
webView1.RemoveFromSuperview();
webView1 = null;
}https://stackoverflow.com/questions/71470814
复制相似问题