2

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

1 Answer 1

2

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).

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! At the moment I'm working on something like this link, but I will try your idea next. I know your browser... I have studied the code very closely. It's a little too much for my needs as I am doing something very simple and very custom for a client. Thank you!
Yes, the ideas from that link should provide you a good direction and set of alternatives to accomplish this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.