How can I run JavaScript on a specific side only?

I’ve created a JavaScript timer and placed it in the front template of the card to do some tweaks. However, when I test it during review, it continues to run even when I flip to the back side (this issue doesn’t occur on AnkiDroid), it seems that Anki runs the scripts once in the beginning of the review session only.

I would like it to run only on the front sides and not persist to the back side (i don’t want communication between scripts of the front and the back templates)

Thank you!

Any reponse ?

The front & back sides of a card are considered a single web page, so they share state.

You can work around the issue by adding some unique HTML to the front/back side then checking for it and deciding whether to run/stop the timer accordingly.


Thank you abdo!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.