Skip to content

Use pagehide instead of unload in MeshCommander pages - #8426

Open
SanderYaz wants to merge 1 commit into
Ylianst:masterfrom
SanderYaz:fix/commander-use-pagehide
Open

SanderYaz wants to merge 1 commit into
Ylianst:masterfrom
SanderYaz:fix/commander-use-pagehide

Conversation

@SanderYaz

Copy link
Copy Markdown

Fixes #8335

What

Replace onunload="cleanup()" with onpagehide="cleanup()" on the <body> tag of all eleven public/commander*.htm pages.

Why

Chrome is deprecating the unload event and, with --enable-features=DeprecateUnload, blocks it with Permissions policy violation: unload is not allowed in this document. commander.ashx is loaded in a hidden iframe on every signed-in page, so the error shows up in the console of every session. When MeshCentral is embedded through allowedFramingOrigins, the embedding site also has to allow unload for it to work.

pagehide is the recommended replacement: it fires on navigation and on tab or iframe close, and it is not covered by the deprecation.

Scope

  • Only the one attribute changes in each file. I reverted the substitution on every file and compared it byte for byte with HEAD; all 11 matched, so nothing else (BOM, line endings, the minified body) was touched.
  • Each file defines cleanup() itself, so the handler resolves in every locale.

Not covered

  • I did not test in Chrome with the deprecation flag enabled; the change follows the issue's suggestion and the documented pagehide behaviour. A quick check from someone with the flag set up would be welcome.
  • The issue also asks for a supported way to override these files from meshcentral-web/public. This PR does not touch handleMeshCommander; I left that as a separate design decision.
  • These pages look like build output from MeshCommander. If they are regenerated from a separate source, the same change needs to go there as well.

🤖 Generated with Claude Code

Chrome blocks the unload event when the DeprecateUnload feature is on
(Permissions policy violation: unload is not allowed in this document).
Switch the body handler of all commander*.htm pages to onpagehide.

Fixes Ylianst#8335

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@si458

si458 commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

this should be fixed upstream also - https://github.com/Ylianst/MeshCommander
reason being is meshcentral includes a stripped down version of meshcommander.
so its better to fix it upstream, then we can update it here
but thats for finding the fix tho 👍

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

commander*.htm usa onunload inline: erro "Permissions policy violation: unload is not allowed in this document" no Chrome com a deprecação do unload

2 participants