import javafx.scene.web.WebView import tornadofx.*
class WbView:View(){ lateinit var wb:WebView override val root=vbox{ button("Execute Javascript (Call from JavaFX)"){ action{ wb.engine.executeScript("changeBgColor()") } } webview { wb=this val str=""" <html> <head> <script language='javascript'> function changeBgColor() { var color= document.getElementById('color').value; document.body.style.backgroundColor= color; } </script> </head> <body> <h2>This is Html content</h2> <b>Enter Color:</b> <input id='color' value='yellow' /> <button onclick='changeBgColor();'>Change Bg Color</button> </body> </html> """.trimIndent() engine.loadContent(str) } } }