# "document" VS "wwLib.getFrontDocument()"

**URL:** <https://community.weweb.io/t/document-vs-wwlib-getfrontdocument/8929>\
**Category:** Ask us anything\
**Tags:** design\
**Created:** [June 3, 2024, 8:48am UTC](https://community.weweb.io/t/document-vs-wwlib-getfrontdocument/8929 "2024-06-03T08:48:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unlustucru](https://avatars.discourse-cdn.com/v4/letter/u/e36b37/32.png) [@unlustucru](https://community.weweb.io/u/unlustucru)\
**Post date:** [June 3, 2024, 8:48am UTC](https://community.weweb.io/t/document-vs-wwlib-getfrontdocument/8929/1 "2024-06-03T08:48:37Z")

</div>

I’ve just stumbled upon [this article](https://www.weweb.io/blog/the-document-object-model-dom-explained-for-no-coders), which states:

> As you can see, we access the DOM through a **document** variable which is common among all browsers (chrome, firefox, arc, etc). But, in the case of WeWeb, while in the no-code editor, that won’t work.
> 
> Indeed, while working in WeWeb, your app is created inside an iframe (kind of a webpage inside the current webpage). To select it, you should replace **document** by **wwLib.getFrontDocument()**.
> 
> So, for the first example, where we select an element by its **id** , it becomes:
> 
> ```auto
> var element = wwLib.getFrontDocument().getElementById("myElement");
> 
> ```

I’m a bit surprised, since so far I’ve been using standard Javascript formulas, such as `document.getElementById("myElement");` without problem.

Just wanted to check with y’all if I should go ahead and convert all my `document.getElementById("myElement");` to `wwLib.getFrontDocument().getElementById("myElement");` in order to avoid any potential problems I might not be aware of in the future, or if I can safely stick to the standard `document.getElementById("myElement");`?

---

<div class="post-metadata">

**Author:** ![raydeck](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raydeck/32/384_2.png) [@raydeck](https://community.weweb.io/u/raydeck)\
**Post date:** [June 3, 2024, 6:43pm UTC](https://community.weweb.io/t/document-vs-wwlib-getfrontdocument/8929/2 "2024-06-03T18:43:48Z")

</div>

WHen in the editor, weweb utilizes an iFrame and can get confused when referencing document and window. That’s why wwLib.getFrontWindow and wwLib.getFrontDocument are useful.

In published contexts, they just point to document and window objects, so there’s no impact.

---

<div class="post-metadata">

**Author:** ![unlustucru](https://avatars.discourse-cdn.com/v4/letter/u/e36b37/32.png) [@unlustucru](https://community.weweb.io/u/unlustucru)\
**Post date:** [June 4, 2024, 12:35pm UTC](https://community.weweb.io/t/document-vs-wwlib-getfrontdocument/8929/3 "2024-06-04T12:35:24Z")

</div>

Thank you @raydeck
