# Javascript not working properly on AnkiMobile?

**URL:** <https://forums.ankiweb.net/t/javascript-not-working-properly-on-ankimobile/224>\
**Category:** Help\
**Created:** [June 16, 2020, 5:38pm UTC](https://forums.ankiweb.net/t/javascript-not-working-properly-on-ankimobile/224 "2020-06-16T17:38:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![b1-66er](https://avatars.discourse-cdn.com/v4/letter/b/aeb1de/32.png) [@b1-66er](https://forums.ankiweb.net/u/b1-66er)\
**Post date:** [June 16, 2020, 5:38pm UTC](https://forums.ankiweb.net/t/javascript-not-working-properly-on-ankimobile/224/1 "2020-06-16T17:38:51Z")

</div>

Hi! I am using a deck i’ve downloaded as a shared deck (PGN Chess Flashcards [https://ankiweb.net/shared/info/340753088](https://ankiweb.net/shared/info/340753088)) and it is working on windows 10 and AnkiDroid app. It is not working properly on AnkiMobile app though. I can only see the text but not the image which I assume is being generated with javascript.

Hardware: Ipad Pro (12.9-inch)  
Model Number ML0Q2LL/A  
Software Version: 13.3.1  
AnkiMobile version: 2.0.59 (20059.3)

I’ve asked the author of the shared deck and this is his reply:

“Your problem doesn’t have anything to do with this addon which only works on desktop. The problem you described is javascript related, and pertains to the original code in the card templates. I’m afraid I don’t know much about Apple products to help here.”

I know he said it works only in desktop but I shared the deck from my pc to my android and it is working perfectly (not working in ankiweb though when i’m on android but that’s another story).

I hope you can help me because the android phone screen is very very small and I think the deck will look awesome on the ipad like the other decks 🙂

---

<div class="post-metadata">

**Author:** ![p4nix](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/p4nix/32/81_2.png) [@p4nix](https://forums.ankiweb.net/u/p4nix)\
**Post date:** [June 16, 2020, 10:04pm UTC](https://forums.ankiweb.net/t/javascript-not-working-properly-on-ankimobile/224/2 "2020-06-16T22:04:15Z")

</div>

Anki has no official support for JS, so there is a kind of “just hope that it works, and if it doesn’t, it’s your problem”-policy: [https://docs.ankiweb.net/#/templates/styling?id=javascript](https://docs.ankiweb.net/#/templates/styling?id=javascript)

Could it have to do with the fact that the Anki deck needs external JS from chesstempo? I mean you do need the JSBooster add-on on Desktop, and Android/AnkiDroid might be more open than AnkiMobile/iOS. Maybe it’s possible to localise their javascript in your collection folder and use it from there.

[https://ankiweb.net/shared/info/1388898263](https://ankiweb.net/shared/info/1388898263)

This also seems interesting, and I could get it to run on my iPad by changing the javascript and pressing Enter in the type field (changed timeout from 200 ms to 2000 ms). Maybe adjustments can be made to make it work instantly, but I can see the chessboard - so it’s only a matter of some tweaks. However, I am not really interested into doing this right now, as I don’t plan to learn chess in the next few weeks. Feel free to try it though, it definitely will work 🙂

---

<div class="post-metadata">

**Author:** ![boydkelly](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@boydkelly](https://forums.ankiweb.net/u/boydkelly)\
**Post date:** [June 25, 2020, 4:27pm UTC](https://forums.ankiweb.net/t/javascript-not-working-properly-on-ankimobile/224/3 "2020-06-25T16:27:53Z")

</div>

I was also wanting to replace the Hint link with a button. I followd the example here: [https://chrisk91.me/2018/04/28/Adding-Hint-fields-in-Anki.html](https://chrisk91.me/2018/04/28/Adding-Hint-fields-in-Anki.html)

And it works fine on the deskotp, but not in AnkiMobile. If any js gurus have any suggestions they would be welcome. Otherwise this isn’t some esoteric thing. It just displays text on click. Normally should work with java in android…

---

<div class="post-metadata">

**Author:** ![mmdj2](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/mmdj2/32/124_2.png) [@mmdj2](https://forums.ankiweb.net/u/mmdj2)\
**Post date:** [June 25, 2020, 4:43pm UTC](https://forums.ankiweb.net/t/javascript-not-working-properly-on-ankimobile/224/4 "2020-06-25T16:43:47Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/aa1aadb8f62ff0d6ffa9e59f5ff3fcfb4225755c.png) ![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/bf58188e600c8332b5ceaf51e59d80d73c9be46b.png)

> **Show code**
>
> ```auto
> {{#Hint}}
> <br>
> ﻿<button class=hint onclick="this.style.display='none';document.getElementById('myHint').style.display='inline-block';return false;" style="display: inline-block" accesskey="4"><div position=bottom>
> Show Hint</div></button><div id="myHint" class=hint style="display: none;">{{Hint}}</div>
> {{/Hint}}
> 
> <script>
> function showhide() {
> if (document.getElementById('hide').style.display=='none')
> {text = document.getElementById('hide');
> text.style.display=''}
> else
> {text = document.getElementById('hide');
> text.style.display='none'}
> }
> </script>
> 
> ```

this works for me on both devices.

if you want the button to show/hide hint you can change it like this

> **Show code**
>
> ```auto
> {{#Hint}}
> <br>
> ﻿<button class=hint onclick="showhide()" style="display: inline-block" accesskey="4"><div position=bottom>
> Show Hint</div></button><br>
> <div id="hide" class=hint style="display: none;">{{Hint}}</div>
> {{/Hint}}
> 
> <script>
> function showhide() {
> if (document.getElementById('hide').style.display=='none')
> {text = document.getElementById('hide');
> text.style.display='inline'}
> else
> {text = document.getElementById('hide');
> text.style.display='none'}
> }
> </script>
> 
> ```

---

<div class="post-metadata">

**Author:** ![boydkelly](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@boydkelly](https://forums.ankiweb.net/u/boydkelly)\
**Post date:** [July 18, 2020, 4:35pm UTC](https://forums.ankiweb.net/t/javascript-not-working-properly-on-ankimobile/224/5 "2020-07-18T16:35:45Z")

</div>

Hey! Thanks for the reply and suggestion. Just in case anyone has the same issue, I also was able to cobble up a css only solution that also works great.

CSS:

```
.hint {
  display: none; }

#trigger:checked + .hint {
  display: block;
  text-align: center; }

.hint-row, .example-row {
  display: flex;
  align-items: center;
  justify-content: left;
  padding: 0px 0px 6px 6px; }

```

Card:

```
{{#Hint1}}
<div class= "jl hint-row">
  <label for="trigger"></label>
  <div class=badge>Hint</div>
  <input id="trigger" type="checkbox">
  <div class="hint">{{Hint1}}</div>
</div>
{{/Hint1}}

```

 ![anki2](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/4fff42a55b60ab06e43271140e008516f78cff3b.png)

---

<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:** [May 1, 2023, 7:53am UTC](https://forums.ankiweb.net/t/javascript-not-working-properly-on-ankimobile/224/7 "2023-05-01T07:53:22Z")

</div>


