# Scripts in the HTML Editor

**URL:** <https://forums.ankiweb.net/t/scripts-in-the-html-editor/52719>\
**Category:** Help\
**Created:** [December 4, 2024, 2:24pm UTC](https://forums.ankiweb.net/t/scripts-in-the-html-editor/52719 "2024-12-04T14:24:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![c0nst1](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@c0nst1](https://forums.ankiweb.net/u/c0nst1)\
**Post date:** [December 4, 2024, 2:24pm UTC](https://forums.ankiweb.net/t/scripts-in-the-html-editor/52719/1 "2024-12-04T14:24:47Z")

</div>

I have the Problem, that i want to insert a Javascript Code in an Anki Card via the HTML Editor and it keeps getting deleted.  
I know this is, due to security risks involving Javascripts and i also know that you can insert Javascript via the template-editor.  
Now in my case the problem with this is that i want to create quite a few Cards with different Scripts and the option to do it via templates would simply get to messy over time(imagine having around 100 to 200 templates).  
So does anyone know how to bypass this security feature or knows an addon that does this?

---

<div class="post-metadata">

**Author:** ![jhhr](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/jhhr/32/21339_2.png) [@jhhr](https://forums.ankiweb.net/u/jhhr)\
**Post date:** [December 4, 2024, 3:37pm UTC](https://forums.ankiweb.net/t/scripts-in-the-html-editor/52719/2 "2024-12-04T15:37:04Z")

</div>

Hi, `eval` seems to work in card templates: [eval() - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval)

Note the big red warning box at the top.

> **I suppose as you long you ensure you are the only one who ever edits your cards, you're mostly safe. Don't put code someone else wrote for you in your cards, if you do this.**
>
> **Your\_code\_field:**  
> Don’t put `<script>` tags in the field, instead write the code without that into the raw html editor.
> 
> ```auto
> console.log('hello world');
> 
> ```
> 
> **Your card template:**
> 
> ```auto
> <script>
> // Goodbye, security
> eval(`{{Your_code_field}}`);
> </script>
> 
> ```

---

<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:** [January 3, 2025, 3:37pm UTC](https://forums.ankiweb.net/t/scripts-in-the-html-editor/52719/3 "2025-01-03T15:37:18Z")

</div>

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