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