It is currently 8 June 2025, 6:28 Advanced search

chiudere scheda browser (chrome) client side

Domande e risposte su come utilizzare Instant Developer Cloud al meglio

chiudere scheda browser (chrome) client side

Postby majinbu » 16 December 2024, 8:45

Ciao,
sto cercando di fare in modo che in una determinata situazione l'applicazione chiuda la tab del browser lato client. Non mi va bene terminare l'applicazione lato server.

Ho tentato in vari modi:

yield app.eval('window.close();');
yield app.eval('close();');
yield app.eval("open('https://link/', '_self').close();"); // questo sembra funzionare nell'IDE ma in produzione no

Qualche suggerimento? Probabilmente mi perdo in una banalità

Grazie
majinbu
 
Posts: 34
Joined: 4 June 2020, 8:15

Re: chiudere scheda browser (chrome) client side

Postby fgiardini » 19 December 2024, 9:04

Ciao,
nei browser moderni l'utilizzo di close() è limitato:
The Window.close() method closes the current window, or the window on which it was called.

This method can only be called on windows that were opened by a script using the Window.open() method, or on top-level windows that have a single history entry. If the window doesn't match these requirements, an error similar to this one appears in the console: Scripts may not close windows that were not opened by script.

(https://developer.mozilla.org/en-US/doc ... ndow/close)

Probabilmente la tua situazione non rientra in uno di questi casi.
Francesco
fgiardini
 
Posts: 17
Joined: 10 March 2022, 16:37

Re: chiudere scheda browser (chrome) client side

Postby majinbu » 19 December 2024, 10:10

Grazie,
avevo trovato questa soluzione qui: yield app.eval("open('https://link/', '_self').close();"); ma purtroppo niente.
Pazienza :)
majinbu
 
Posts: 34
Joined: 4 June 2020, 8:15


Return to Tips & Tricks - Cloud

Who is online

Users browsing this forum: No registered users and 8 guests

cron