#Eval js on window with external url not working

4 messages · Page 1 of 1 (latest)

wintry pumice
#

I am trying to execute js on a newly created window like this:

#[tauri::command]
async fn open_app(url: String, app: String, handle: tauri::AppHandle) -> Result<(), ()> {
    let app_window = tauri::WindowBuilder::new(
        &handle,
        app,
        tauri::WindowUrl::External(url.parse().unwrap())
    ).build().unwrap();
    println!("opened window!");
    app_window.eval("(function () {alert('foo');})()").unwrap();
    Ok(())
}

However it is not wokring. No JS ist executed.
What I am doing wrong?

https://docs.rs/tauri/latest/tauri/window/struct.WindowBuilder.html#method.initialization_script does work

topaz willow
wintry pumice
#

No error there. I have

"tauri": {
    "allowlist": {
      "all": true,
topaz willow
#

Are you actually invoking that command at any point?