Hello,
So as the title says, I want to get the height of a DIV in a webview. I tried things like this:
But it will only return:
Thanks in advance for your help.
[EDIT] Solved in post #3 Thanks to warwound.
So as the title says, I want to get the height of a DIV in a webview. I tried things like this:
B4X:
Private we, temp As JavaObject
Private js As jScriptEngine
we.InitializeNewInstance("javafx.scene.web.WebEngine",Null)
temp = wvMessage
we = temp.RunMethod("getEngine",Null)
Dim s As StringBuilder
s.Initialize
s.Append("<!DOCTYPE html>")
s.Append("<html>")
s.Append("<head>")
s.Append("<style Type='text/css'>")
s.Append("a:link {color:#3D8FAB;} ")
s.Append("a:visited {color:#2b6a7f;}")
s.Append("a:hover {color:#66cbed;}")
s.Append("a:active {color:#ffffff;}")
s.Append("</style>")
s.Append("</head>")
s.Append("<body bgcolor=#000000>")
s.Append("<div id='message' style='color:" & sColor & "; font-size:0.8em; font-family:arial;'>")
s.Append(sMessage.Replace(CRLF, "<br>").Replace(TAB, "    "))
s.Append("</div>")
s.Append("</body>")
s.Append("</html>")
wvMessage.LoadHtml(s)
Dim Height As Object
js.enginePut("doc",we.RunMethod("getDocument",Null))
js.evalString("var height = doc.getElementById('message').clientHeight;") ' get the height of the div
Height = js.engineGet("height")
But it will only return:
B4X:
java.lang.NumberFormatException: For input string: "sun.org.mozilla.javascript.internal.Undefined@28fbb9"
Thanks in advance for your help.
[EDIT] Solved in post #3 Thanks to warwound.
Last edited: