Hi, guys, I have a webView in the fragment and whe...
# android
d
Hi, guys, I have a webView in the fragment and when I open some url that belongs to, for example, twitter, the page is shown but I can’t open any external link that are provided in tweets. Those external links actually all have set
target="_blank"
and I have appropriate js script injected when
onPageFinished
is called:
Copy code
webView.webViewClient = object : WebViewClient() {

    override fun onPageFinished(view: WebView, url: String?) {
        Timber.d("onPageFinished: url = $url")
        view.loadUrl("javascript: var allLinks = document.getElementsByTagName('a'); if (allLinks) {var i;for (i=0; i<allLinks.length; i++) {var link = allLinks[i]; var target = link.getAttribute('target'); if (target && target == '_blank') { link.removeAttribute('target');}}}")
    }
This handling works for websites that provide their content immediately and this function is called when actual page loading is finished, but loading tweets is done asynchronously long after that. Does anyone have any idea how can I handle those newly injected urls in the page and change their
target
attributes ?
google 3
stackoverflow 3
@kenkyee, thank you for your priceless and illuminated reaction with StackOverflow and Google icons!!! I would never thought to check the answer there before posting this question here. You help is precious.
👎 3
k
Read the channel description. This is for jetbrains to help with kotlin issues on android
We really should just rename this channel #android-kotlin-issues
Is you want to ask generic Android questions, there's the big Android United community. Jetbrains watches these channels to help with kotlin issues. If you ask generic unrelated questions, you just increase their noise ratio so they're less likely to see real Android kotlin issues
1
r
If you have the power to rename it, go for it.
k
I really wish I could 😔
g
Rename will not help
😂 1