Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
How to use ui.Webview.evaluate_javascript()?
-
@AceNinjaFire Or it is better to try @mikael 's WKWebView
-
Damn!!!
Thank you!! I have no experience with using the objc_util module at all😅, but I’ll have to look at it now. You helped me solve a problem I was having lol, I appreciate it.
Would you know of a good tutorial for using the module? I’ve looked at the doc before but it’s not an easy read.
-
@AceNinjaFire said:
it’s not an easy read.
That's sure, at least 😀
I don't know any other doc but we learn by practicing or by finding some examples in this marvelous forum -
@AceNinjaFire I just wanted to delete my post because I told myself that it probably did not respond to your request ...Perhpas, it was a little bit too complex to start. Sorry for that.
-
You’re good lol. Complex or not I appreciate it, since the only way I’ll learn is by example or experimentation. I’m using the example you gave to reference to the objc_util module and what it does. I’m still far from understanding it but it’ll definitely be useful if it works the way I think it does.
EDIT: also you introduced a few ui functions I was unaware of which helped me solve another problem I was having lol. I really need to read the docs more completely going forward.
-
Was the original request how to get data back from a JavaScript script? Or how to execute any JavaScript at all? Are you still looking for an answer there?
-
@JonB You are right to ask it. That's the reason why I sincerely wanted to remove my post because I answered too quickly, but he seemed to be happy with my answer 😢 thus I could not remove it.
-
Yea that was my original question, but after looking at @cvp ‘s code I realized you had to structure it in a way to get the value normally (document.location.href) without assigning it to a value like (var url = document.location.href).
cvp answered my original question and answered a question I didn’t even have yet. So yea I was happy with it lol.
-
This post is deleted! -
By the way, if you ever need to communicate from JavaScript to python (for instance, if you are using JavaScript UI elements) you can implement a custom webview delegate. Also, if you are doing much js coding you may want to implement on_error logging... See
https://forum.omz-software.com/topic/1804/debugging-in-javascript-in-pythonista
-
Dang thanks man, and that’s definitely something I’ll look into. I’ve been looking for a reason to delve into js again after my initial dive into it. What types of projects have you done bridging the two together?