-
Notifications
You must be signed in to change notification settings - Fork 92
target="_blank" on href elements has no effect #51
Comments
I have same issue. |
@lgrimes @huacnlee any links with As a test, I'd try setting your own code to be the |
My case: extension TurbolinksSessionLib: SessionDelegate {
func sessionDidLoadWebView(session: Session) {
// [breakpoint] looks like there may have no call
session.webView.navigationDelegate = self
}
}
extension TurbolinksSessionLib: WKNavigationDelegate {
func webView(webView: WKWebView, decidePolicyForNavigationAction navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> ()) {
let url = navigationAction.request.URL
if (url?.host != NSURL(string: ROOT_URL)?.host) {
let safariViewController = SFSafariViewController(URL: url!)
topNavigationController?.presentViewController(safariViewController, animated: true, completion: nil)
} else {
actionToPath((url?.path)!, withAction: .Advance)
}
decisionHandler(.Cancel)
}
} I had try to add breakpoint on |
In extension of SessionDelegate, i am only overriding Im setting the session in my ViewController like such:
Ive also set some breakpoints in |
Same issue here. |
Any new ideas here? I've got a very simple application with a SessionDelegate overriding the minimum just as @lgrimes described, with the addition of |
Update! Fixed it thanks to finding this question about how to handle
And assigned it to the
|
I'm having the same issue. I already tried out on the demo application, and it has the same problem. Removing |
@zachwaugh, I check out the code. This method, From the apple documentation, https://developer.apple.com/reference/webkit/wknavigationaction/1401918-targetframe, it returns nil because it is new window navigation. |
Thanks for digging in @chamnap! That was the issue, our default check was too restrictive. I just pushed a change that opens all links that Turbolinks doesn't handle directly to open in Safari. That should make the My apologies for not fixing this sooner, I was testing in our app, which had custom handling in place for the |
Description
We have standard href link which is meant to take the user out of the app and to http://facebook.com/shared/sharer.php.
<a class="Share-link m-facebook" href="http://www.facebook.com/sharer/sharer.php?u=ourdomain&title=blah blah" target="_blank"></a>
As we are using the same on our web app, we want the link to take the user to a new window, rather than reloading the current one (hence target="_blank"). This is working completely fine. With this on the tag, the iOS app receives no callback of any kind that a link has been clicked. Nothing from the WKWebView delegate methods is triggered. openExternalURL in the Session is never called.
If however, we remove target="_blank" then the link will open in an external safari window as expected. Our work around has been to pass a flag when the page is loaded from a native webview that will not apply the target tag to the element.
Is this expected functionality?
The text was updated successfully, but these errors were encountered: