pub fn run_script<T>(script: T)
Expand description
Runs the given JavaScript script string with the eval()
JS function, in the calling thread,
using the emscripten-defined emscripten_run_script
.
If you need to run the script in the main thread, check out run_script_main_thread
.
§Arguments
script
- The script to execute.
§Examples
run_script("alert('Hello world')");
// The `.escape_unicode()` method makes it safe to pass untrusted user input.
run_script(
format!(
r##"
document.querySelector("#this-is-secure").innerHTML = "{}"
"##,
"untrusted user input".escape_unicode()
)
);