0

GeckoView doesn't open links with target="_blank" attributes or window.open calls from JS in the current session - it simply does nothing on these interactions (same as iOS WKWebview).

How to default load new tabs/windows in the current GeckoSession?

Matt Bennett
  • 120
  • 9

1 Answers1

1

As noted in the onLoadRequest docs, you can override onLoadRequest with something like this (kotlin):

private fun createNavigationDelegate() = object : GeckoSession.NavigationDelegate {
    override fun onLoadRequest(session: GeckoSession, request: GeckoSession.NavigationDelegate.LoadRequest): GeckoResult<AllowOrDeny> {
        if (request.target === NavigationDelegate.TARGET_WINDOW_NEW) {
            session.loadUri(request.uri)
        }

        return GeckoResult.fromValue(AllowOrDeny.ALLOW)
    }
}

From the docs linked above:

For example, this can be used to override the behavior of TAGET_WINDOW_NEW requests, which defaults to requesting a new GeckoSession via onNewSession.

Matt Bennett
  • 120
  • 9