# Help with switching to the back of card

**URL:** <https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070>\
**Category:** Development\
**Created:** [March 11, 2025, 12:09pm UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070 "2025-03-11T12:09:23Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![SuhasK](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SuhasK](https://forums.ankiweb.net/u/SuhasK)\
**Post date:** [March 11, 2025, 12:09pm UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/1 "2025-03-11T12:09:23Z")

</div>

I got this code to switch to the back of the card from [here](https://forums.ankiweb.net/t/trigger-show-answer-in-javascript/18158/3).

```auto
	if (typeof pycmd !== "undefined") {
		pycmd("ans")
	} else if (typeof study !== "undefined") {
		study.drawAnswer()
	} else if (typeof AnkiDroidJS !== "undefined") {
		showAnswer()
	} else if (window.anki && window.sendMessage2) {
		window.sendMessage2("ankitap", "midCenter")
	}

```

It seems to be working only in Anki Desktop (I have tried on Anki Desktop, AnkiWeb and AnkiDroid)  
Could anybody help me to switch to the back of the card in the other versions of Anki?

---

<div class="post-metadata">

**Author:** ![abdo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/abdo/32/654_2.png) [@abdo](https://forums.ankiweb.net/u/abdo)\
**Post date:** [March 16, 2025, 4:39pm UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/2 "2025-03-16T16:39:40Z")

</div>

The AnkiDroid part might be broken due to this: [[BUG]: globalThis.AnkiDroidJS is undefined · Issue #16357 · ankidroid/Anki-Android · GitHub](https://github.com/ankidroid/Anki-Android/issues/16357)  
You can replace the `typeof AnkiDroidJS !== "undefined"` part with just `window.showAnswer` to fix the issue.

---

<div class="post-metadata">

**Author:** ![SuhasK](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SuhasK](https://forums.ankiweb.net/u/SuhasK)\
**Post date:** [March 16, 2025, 8:04pm UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/3 "2025-03-16T20:04:40Z")

</div>

This will work for all platforms, right? (I can’t test on AnkiMobile, but wish to be aware which platform this might not work on, so that I can add a disclaimer when sharing the deck)

---

<div class="post-metadata">

**Author:** ![abdo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/abdo/32/654_2.png) [@abdo](https://forums.ankiweb.net/u/abdo)\
**Post date:** [March 16, 2025, 8:21pm UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/4 "2025-03-16T20:21:10Z")

</div>

I can only guarantee this will work on the computer Anki and AnkiDroid. AnkiMobile doesn’t have a reliable way as far as I know. The method shared in the linked thread is probably broken now. See disclaimer there:

> [@Trigger "show answer" in javascript](https://forums.ankiweb.net/t/trigger-show-answer-in-javascript/18158/7):
>
> Please bear in mind that these calls are not part of a public API, and they may break the next time this part of the code is refactored, so any shared decks/notetypes you distribute should be prepared for the symbols to be missing or to not respond.

---

<div class="post-metadata">

**Author:** ![SuhasK](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SuhasK](https://forums.ankiweb.net/u/SuhasK)\
**Post date:** [March 16, 2025, 8:39pm UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/5 "2025-03-16T20:39:04Z")

</div>

I just need to call window.showAnswer, right? I tested it on a basic template and that isn’t changing to the back of the card.

```auto
{{Front}}
<script>
window.ShowAnswer
</script>

```

---

<div class="post-metadata">

**Author:** ![abdo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/abdo/32/654_2.png) [@abdo](https://forums.ankiweb.net/u/abdo)\
**Post date:** [March 16, 2025, 8:49pm UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/6 "2025-03-16T20:49:00Z")

</div>

On computer Anki: `pycmd('ans')`.  
On AnkiDroid: `window.showAnswer()`.

---

<div class="post-metadata">

**Author:** ![SuhasK](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SuhasK](https://forums.ankiweb.net/u/SuhasK)\
**Post date:** [March 16, 2025, 8:55pm UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/7 "2025-03-16T20:55:47Z")

</div>

And for AnkiWeb? The initial one did not work.

---

<div class="post-metadata">

**Author:** ![abdo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/abdo/32/654_2.png) [@abdo](https://forums.ankiweb.net/u/abdo)\
**Post date:** [March 16, 2025, 9:00pm UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/8 "2025-03-16T21:00:47Z")

</div>

The `study.drawAnswer()` part was probably for AnkiWeb, but I think it’s now broken.

---

<div class="post-metadata">

**Author:** ![SuhasK](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SuhasK](https://forums.ankiweb.net/u/SuhasK)\
**Post date:** [March 16, 2025, 9:12pm UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/9 "2025-03-16T21:12:33Z")

</div>

I could only get this to work for computer, not AnkiDroid.

---

<div class="post-metadata">

**Author:** ![abdo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/abdo/32/654_2.png) [@abdo](https://forums.ankiweb.net/u/abdo)\
**Post date:** [March 17, 2025, 2:01am UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/10 "2025-03-17T02:01:58Z")

</div>

> [@SuhasK](#):
>
> ```auto
> <script>
> window.ShowAnswer
> </script>
> 
> ```

This is the correct code:

```auto
<script>
window.showAnswer()
</script>

```

---

<div class="post-metadata">

**Author:** ![SuhasK](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SuhasK](https://forums.ankiweb.net/u/SuhasK)\
**Post date:** [March 17, 2025, 5:20am UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/11 "2025-03-17T05:20:36Z")

</div>

Yeah, I used this for AnkiDroid and it didn’t work.

---

<div class="post-metadata">

**Author:** ![abdo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/abdo/32/654_2.png) [@abdo](https://forums.ankiweb.net/u/abdo)\
**Post date:** [March 17, 2025, 12:12pm UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/12 "2025-03-17T12:12:44Z")

</div>

Weird. Worked for me in a basic note type.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [April 16, 2025, 12:13pm UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/13 "2025-04-16T12:13:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Danika\_Dakika](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/danika_dakika/32/17815_2.png) [@Danika\_Dakika](https://forums.ankiweb.net/u/Danika_Dakika)\
**Post date:** [April 30, 2025, 8:11am UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/14 "2025-04-30T08:11:01Z")

</div>



---

<div class="post-metadata">

**Author:** ![Danika\_Dakika](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/danika_dakika/32/17815_2.png) [@Danika\_Dakika](https://forums.ankiweb.net/u/Danika_Dakika)\
**Post date:** [May 30, 2025, 8:11am UTC](https://forums.ankiweb.net/t/help-with-switching-to-the-back-of-card/57070/15 "2025-05-30T08:11:58Z")

</div>

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