# Not work p5.js in Elementor external window (iframe)

**URL:** <https://discourse.processing.org/t/not-work-p5-js-in-elementor-external-window-iframe/43681>\
**Category:** p5.js\
**Created:** [January 12, 2024, 9:33am UTC](https://discourse.processing.org/t/not-work-p5-js-in-elementor-external-window-iframe/43681 "2024-01-12T09:33:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serhii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/serhii/32/19212_2.png) [@Serhii](https://discourse.processing.org/u/Serhii)\
**Post date:** [January 12, 2024, 9:33am UTC](https://discourse.processing.org/t/not-work-p5-js-in-elementor-external-window-iframe/43681/1 "2024-01-12T09:33:33Z")

</div>

Hi all. Problem with iframe Elementor in Frontend editor, library not find element, when i create canvas. Any idea? Thanks!

const canvasAudio = createCanvas(windowWidth, windowHeight);  
canvasAudio.parent(‘audio\_visualizers’);

 ![Screenshot 2024-01-09 163516](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/a/a/aa998e8d6433a786537b0e96f2404e7c10253a6b.jpeg)

---

<div class="post-metadata">

**Author:** ![Serhii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/serhii/32/19212_2.png) [@Serhii](https://discourse.processing.org/u/Serhii)\
**Post date:** [January 12, 2024, 10:58am UTC](https://discourse.processing.org/t/not-work-p5-js-in-elementor-external-window-iframe/43681/2 "2024-01-12T10:58:26Z")

</div>

This problem similar with isotope and now problem in p5.js

> <https://github.com/metafizzy/isotope/issues/1456>
>
> In \[Elementor \](https://elementor.com/), DOM elements are created in an external… window (iframe).
> It turns out that DOM elements are not created from window.HTMLElement but are created from window.parent.HTMLElement (iframe).
> Because of this, DOM elements do not pass this check: https://i.imgur.com/4kn3npZ.jpg
> To avoid this, I have to do this: https://i.imgur.com/XArW7wr.jpg

---

<div class="post-metadata">

**Author:** ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)\
**Post date:** [January 27, 2024, 2:22pm UTC](https://discourse.processing.org/t/not-work-p5-js-in-elementor-external-window-iframe/43681/3 "2024-01-27T14:22:27Z")

</div>

The `parent()` function in p5.js is used to attach the canvas to a specific HTML element. If you’re specifying `parent('audio_visualizers')`, make sure that an element with the ID `audio_visualizers` exists in the DOM. In the context of an iframe, it’s important to ensure that this element exists within the same iframe as your p5.js script.

Could you provide a reduced test case or at least a link to the page that shows the issue?
