Kotlin
class MainActivity : AppCompatActivity() {
private lateinit var myWebView: WebView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
myWebView = findViewById(R.id.webView)
// webView setting
myWebView.webViewClient = MyWebViewClient()
myWebView.loadUrl("www.naver.com")
}
inner class MyWebViewClient: WebViewClient() {
override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
myProgressBar.visibility = View.GONE
}
}
}
This code is my android code.
I understand that the WebViewClient class prevents new windows from opening. However, I cannot find the reason for how it prevents new windows from opening. What is the principle by which the WebViewClient class prevents new windows from opening?
I tried to find a solution with ChatGPT and Google, but I couldn't find the answer I was looking for. I don't trust ChatGPT because its reliability is low.