impeto
impeto

Reputation: 350

JavaFX show HTML source for WebView control

I am putting together a browse in JavaFX using the WebView control. Everything is perfect so far, except I don't know how to implement the 'View Page Source' feature, just like in all major browsers, to display the HTML source of the current page. I have ideas, but they would require some doing. I'm hoping there is a quick way given the fact that WebView uses the WebKit engine just like Chrome.

Thanks in advance!

A

Upvotes: 2

Views: 2589

Answers (1)

jewelsea
jewelsea

Reputation: 159486

Implement your own URLStreamHandlerFactory using this tutorial as a guide and cache the incoming documents for later display via a view source function.

To allow for a more straightforward implementation (e.g. a webView.getEngine().getSourceText(), or something like that), you will need to file a jira feature request.

As an aside, I implemented a browser for WebView, which you can adopt stuff from if you wish (it doesn't implement view source at the moment though).

Upvotes: 2

Related Questions