Hi All,
I’m using Eto.Webview in an attempt to create a better looking UI. At the moment I’m trying to return the value of an element from the webview however it is returning empty when it definitely has a value in the html. Am I executing the script correctly?
def GetText(self):
return self.webview.ExecuteScript("document.getElementById('id').value;")
Hi Dale,
That fixed some issues around content display but not the null return from doument.GetElementById.
I just tested it with the following and got the alert which wasn’t happening before.
self.webview.ExecuteScript("alert('this is called from code');")
I also checked to see the type of return from the ExecuteScript and it’s returning an empty string.
Here’s the html:
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>WebView Test</title>
</head>
<body>
<label id="label">Test Label</label>
<input id="inputtext" type="text"><br>
<input id="inputradio" type="radio" value="test"><br>
<select id="select">
<option value="Hello">Hello</option>
<option value="World">World</option>
<option value="Rhino">Rhino</option>
</select>
</body>
Any ideas? Also attached the *.py
webview test.py (1.9 KB)
curtisw
(Curtis Wensley)
July 22, 2020, 11:48pm
4
Hey @jordanmathers.jm ,
You have to write “return” in the script. E.g.
def GetText(self):
return self.webview.ExecuteScript("return document.getElementById('id').value;")
Well then. That was simple! Thanks
1 Like