I'd like to customise the appearance of a website that I am loading, so I created a little
First of I have to state, that I hope you know what you are doing, as these things can seriously damage a web site. So here is what you can do:
You grab the
Document from the
WebEngine, retreave the
head element and add a
style child element to it, containing the src location of the stylesheet you want to add.
Document doc = webView.getEngine().getDocument(); URL scriptUrl = getClass().getResource(pathToAttachedDocument); // pathToAttachedDocument = CSS file you want to attach String content = IOUtils.toString(scriptUrl); // Use Apache IO commons for conveniance Element appendContent = doc.createElement("style"); appendContent.appendChild(doc.createTextNode(content)); doc.getElementsByTagName("head").item(0).appendChild(appendContent);