If I have a Browser
and I call browser.loadURL("view-source:http://www.example.com);
it goes straight to Chromium's source viewer. Is there a way to do the same thing with the loadHTML
or loadData
methods?
Or is there a way to programatically switch it to that view once the page has loaded?
The view-source
URL prefix is a specific URI scheme that is handled by Chromium itself. Therefore, this prefix can be used with URLs only.
The general purpose of the loadHTML()
and loadData()
methods is to load and render the HTML string as a regular web page instead of displaying the source code in the browser. Therefore, there is no straightforward approach to make these methods display the source code instead of rendering the page.
However, you can consider saving the HTML to a temporary file and then load it as shown below:
browser.loadURL("view-source:file:///f:\\data\\contents.html");