Web timers

What is the best way to start a timer when a page opens and stop it when the page loses focus.

I used to set it to mode 0 by default then mode 2 when page is shown and mode 0 when it lost focus, but that does not seem to work anymore.

This is the web engine running on ARM

Normally if you use a WebTimer, since it is part of the page, closing the page will stop it right away. Note that by default Xojo Web does not close WebPages.