target=_blank links don’t open in an Android WebView app when the app has switched on multiple-window support and never handles the new-window request. A WebView has no tabs, so target="_blank" has nowhere to go unless your code decides. Turn multiple-window support off so the link loads in place, or handle onCreateWindow and send the address to the browser.
What Android WebView does with target=_blank links
Android WebView treats target=_blank links as ordinary navigations by default, because multiple-window support is off. In a browser, _blank is “usually a new tab”. A WebView has no tab strip.
The WebSettings reference says that with multiple windows disabled, requests to open new windows from window.open() or from target="_blank" links “will instead be treated as top-level navigations, replacing the current page in the same WebView.”
A link that does nothing means a setting or a callback in the app changed that default.
Which setting causes which symptom
The way the target=_blank link fails points to the setting behind it. Find your symptom here first.
| What you see | Likely cause | Fix |
|---|---|---|
| Tap does nothing at all | setSupportMultipleWindows(true) with no onCreateWindow |
Turn it off, or implement the callback |
| Page replaces your site, no way back | Default behaviour, outside site loaded in place | Route outside links to the browser |
A button that calls window.open() does nothing |
Popup opened without a user gesture, or JavaScript disabled | Enable JavaScript; allow automatic windows only if needed |
| Link leaves the app when you wanted it inside | Your shouldOverrideUrlLoading sends it to an Intent |
Return false for that host |
Fix 1: turn multiple-window support off
Turning multiple-window support off is the simplest fix for target=_blank links that do nothing. The link then loads in the same WebView like any other link.
Search your project for setSupportMultipleWindows. If you find it set to true, check for an onCreateWindow override. The WebSettings reference says that when the setting is true, the onCreateWindow callback “must be implemented by the application.” Skip it, and per the WebChromeClient reference the default implementation “does nothing and hence returns false.” The tap looks dead.
webView.settings.setSupportMultipleWindows(false) // the default
Templates and plugins switch this setting on too, so search library code as well as your own.
Once the link is a normal navigation, your WebViewClient sees it. In shouldOverrideUrlLoading, returning true stops the WebView from loading the address and false lets it load. That one method can keep your own pages inside and send everything else out. The full pattern is in how to open external links in the browser from a WebView app.
My take: a wrapper app should use this fix. You decide by address, and whether the page author typed target="_blank" stops mattering.
Fix 2: handle onCreateWindow and open the browser
Handling onCreateWindow lets you keep multiple-window support on and still send target=_blank links to the browser. Use it when you want normal links inside the app and new-window links outside it, without listing hosts.
The callback doesn’t hand you the address. It hands you a message, and it expects a new WebView back. The WebChromeClient reference says the app should create a new WebView and “send the supplied resultMsg message to its target with the new WebView as an argument.” Chromium’s onCreateWindow notes add that “it is better to not reuse an existing WebView” for the child.
So give the callback a temporary WebView whose only job is to catch the address:
webView.settings.setSupportMultipleWindows(true)
webView.webChromeClient = object : WebChromeClient() {
override fun onCreateWindow(
view: WebView, isDialog: Boolean, isUserGesture: Boolean, resultMsg: Message
): Boolean {
if (!isUserGesture) return false // unwanted popup
val temp = WebView(view.context)
temp.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(v: WebView, request: WebResourceRequest): Boolean {
try {
view.context.startActivity(Intent(Intent.ACTION_VIEW, request.url))
} catch (e: ActivityNotFoundException) {
// no app can open this address
}
v.destroy()
return true
}
}
(resultMsg.obj as WebView.WebViewTransport).webView = temp
resultMsg.sendToTarget()
return true
}
}
The temporary WebView is never added to the screen. Test this on a real phone with both plain links and window.open() buttons, because the two don’t always behave the same.
Non-web addresses need their own handling. A WhatsApp or mailto: link sent to a WebView ends in an error, as explained in fixing ERR_UNKNOWN_URL_SCHEME for WhatsApp links.
The safety rules for new windows
New windows inside a WebView app can mislead users, so Android’s documentation attaches three warnings to onCreateWindow.
First, popups without a tap: apps “should typically not allow windows to be created when the isUserGesture flag is false, as this may be an unwanted popup.”
Don’t lay the new window over your WebView either, since that “may mislead the user about which site they are viewing.” If your app shows no address bar, the reference suggests disallowing new windows entirely.
The last one is the reason I send new windows to the browser. There is “no trustworthy way to tell which page requested the new window.” It could be a third-party iframe, such as an ad. The browser shows the address. Your wrapper doesn’t.
The Chromium notes say WebView “doesn’t support multiple pending popups”, so a page that opens several windows at once won’t work as it does in Chrome.
Why window.open() buttons do nothing
A window.open() call does nothing in a WebView when it runs without a user gesture, or when JavaScript is off. The WebSettings reference describes setJavaScriptCanOpenWindowsAutomatically: its default is false, and “attempts without a user gesture will fail and do nothing.”
The same entry says the user gesture requirement “is enforced even if multiple windows are disabled.”
Take a payment page that opens the bank’s page with window.open() inside a timer, a second after the tap. The call is no longer tied to the tap, so the WebView drops it without an error. Calling window.open() directly in the click handler fixes it. Setting setJavaScriptCanOpenWindowsAutomatically(true) also works, but it lets any script open windows. Chrome DevTools remote debugging will show you which script makes the call.
If the button opens a Google login window, read why Google sign-in fails in a WebView before you change any window settings.
How to fix target=_blank links from the website side
You can fix target=_blank links without touching the app by removing the target attribute on your own site. With no new-window request, the app’s window settings don’t matter.
This is the only option in a no-code WebView app, where you can’t edit WebSettings or add an onCreateWindow handler. WebToAPK Free has that limitation. Its options cover the app name, package name, icon, colour, theme, navigation and the Website, HTML and Text sections. It also says plainly that external links can behave differently in a WebView than in Chrome.
Two things to check on the site:
- Links to your own pages shouldn’t carry
target="_blank"at all. - Pages that depend on
window.openerwon’t get it from a plain_blanklink. Browsers now treattarget="_blank"as ifrel="noopener"were set.
Live website content changes without an app update, so a link fix on the site reaches installed apps right away. PDF links are a common reason people add _blank; opening a PDF in an Android WebView covers that case. The website-to-APK guide covers the build.
FAQ
Why does nothing happen when I tap a target=_blank link in my WebView app?
The app turned on multiple-window support but never handled onCreateWindow. The default onCreateWindow does nothing and returns false, so the new-window request is dropped.
Does Android WebView support target=_blank by default?
Not as a new window. Multiple-window support is off by default, and the WebView then treats a target=_blank link as a normal navigation that replaces the current page.
How do I open target=_blank links in Chrome from a WebView?
Leave multiple-window support off and send outside addresses to the browser in shouldOverrideUrlLoading. Or turn it on and handle onCreateWindow with a temporary WebView that passes the address to an Intent.
Why does window.open() do nothing in my WebView?
WebView blocks window.open() calls that don’t come from a user gesture unless the app calls setJavaScriptCanOpenWindowsAutomatically(true). JavaScript also has to be enabled.
Can I fix target=_blank links without changing the app?
Yes, if the website is yours. Remove the target attribute from the links, or open those pages with a normal link, so the app never gets a new-window request.