Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for target=blank links #783

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ViewModel/BrowserViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,24 @@ final class BrowserViewModel: NSObject, ObservableObject,
_ = createNewTab(url: newUrl)
return nil
}
#else
func webView(
_ webView: WKWebView,
createWebViewWith configuration: WKWebViewConfiguration,
for navigationAction: WKNavigationAction,
windowFeatures: WKWindowFeatures
) -> WKWebView? {
guard let newURL = navigationAction.request.url else { return nil }
if let frame = navigationAction.targetFrame, frame.isMainFrame {
return nil
}
guard newURL.isExternal == false else {
externalURL = newURL
return nil
}
webView.load(navigationAction.request)
return nil
}
#endif

#if os(iOS)
Expand Down