JavaFX stop opening URL in WebView - open in browser instead

前端 未结 9 1233
無奈伤痛
無奈伤痛 2020-12-09 05:12

The embedded WebView browser I am using needs special handling for particular URLs, to open them in the native default browser instead of WebView. The actual browsing part w

9条回答
  •  Happy的楠姐
    2020-12-09 05:59

    Sorry for digging out this old thread but I found another solution that I wanted to share with others who struggle with the same problem. I found a library that has a nice wrapper around the entire issue, see its docs at github.

    Edit: Oh, sry for not telling what the project does: The linked library contains a class that actually implemented all of the code discussed in this thread. The user can simply create a new instance of the WebViewHyperlinkListener-interface that gets automatically called when something (mouse enter, mouse quit, mouse click) happens with the link. Once the handler terminates, it returns a boolean: If the handler returns true, the WebView will not navigate to the linked web page. If the handler returns false, it will.

提交回复
热议问题