I'm developing a browser extension that share code between chrome and safari, basically it's an html page that I load up in a WKWebView on safari app extension (and an iframe on chrome extension).
Everything works fine apart from links that won't open in the safari app extension popover if they have target="_blank"
or are popups like facebook login.
Anyone know if it is possible to have safari open them up as if clicked on in an ordinary safari tab?
I've tried to see if the WKWebView sets a global safari
object in my html content, but it seems not, so this Safari Extension Popover Links does not work (results in ReferenceError: Can't find variable: safari
).
This is how I load the web view in my SafariExtensionViewController:
override func viewDidLoad() {
super.viewDidLoad()
...
self.view.addSubview(webView)
webView.navigationDelegate = self
...
webView.load("\(baseUrl)?url=\(currentUrl)")
}
and an extension to make the load
part work:
extension WKWebView {
func load(_ urlString: String) {
if let url = URL(string: urlString) {
let request = URLRequest(url: url)
load(request)
}
}
}