I have a very simple function in Python that passes a parameter to a function in Javascript
def show_hr(hr):
global web_view
web_view.execute_script("showHr(%d);" % hr)
The function in Javascript looks like this
function showHr(a) {
b = a;
}
This works when I run it on the Python shell, but when I run it from command line, it gives me the error undefined @0: ReferenceError: Can't find variable: showHr
I read about this error and it seems that when there's an error in the Javascript function, it gets overlooked and thus it cannot find the variable. But the same function runs perfectly well when I run the Python program from the shell, so where is this going wrong?
just bumped into your question while looking for something else.
Could this be a scope issue with Webkit being launched a way or the other? Have you tried something like
web_view.execute_script("window.showHr(%d);" % hr)
(if showHr() is defined right in the page, for instance)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.