Execute JavaScript
Execute JavaScript function can be used to execute arbitrary JavaScript code on the browser.
from abstra.forms import execute_js
execute_js("console.log('Hello world!')")
Context
The context parameter can be used to pass variables to the JavaScript code.
a = 2 + 3
execute_js("console.log('Result: ' + $context.result)", context={"result": a})
# Open your console to check the result!
Returning values
The return value of the JavaScript function can be retrieved using the return_value parameter.
referrer = execute_js("document.referrer")
display(f"I see you are coming from {referrer}")