# JavaScript blocks display of the other side of card

**URL:** <https://forums.ankiweb.net/t/javascript-blocks-display-of-the-other-side-of-card/16505>\
**Category:** Card Design\
**Created:** [January 8, 2022, 8:24pm UTC](https://forums.ankiweb.net/t/javascript-blocks-display-of-the-other-side-of-card/16505 "2022-01-08T20:24:13Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [January 9, 2022, 5:46am UTC](https://forums.ankiweb.net/t/javascript-blocks-display-of-the-other-side-of-card/16505/4 "2022-01-09T05:46:50Z")

</div>

The problem here is mainly `document.write()`, which clears the document on first write as far as I understand from [Document.write() - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/write)

Try this front template:

```auto
<div id="front"></div>

<script>
var list = "{{Eng}}".replace("<br>", "\n");
var word = list.match(/.*/);
var front = document.getElementById("front");
front.innerHTML = `Eng: ${word}<br>Rus?`;
</script>

```

You also have to use `var` instead of `let` or you will get errors because Anki uses the same webview for front and back templates and only recycles it periodically.

---

_[View the full topic](https://forums.ankiweb.net/t/javascript-blocks-display-of-the-other-side-of-card/16505)._
