# Cannot access window object in option page

**URL:** <https://discourse.mozilla.org/t/cannot-access-window-object-in-option-page/95903>\
**Category:** Development\
**Tags:** issue\
**Created:** [April 13, 2022, 2:31pm UTC](https://discourse.mozilla.org/t/cannot-access-window-object-in-option-page/95903 "2022-04-13T14:31:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elnath78](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/elnath78/32/23893_2.png) [@elnath78](https://discourse.mozilla.org/u/elnath78)\
**Post date:** [April 13, 2022, 2:31pm UTC](https://discourse.mozilla.org/t/cannot-access-window-object-in-option-page/95903/1 "2022-04-13T14:31:44Z")

</div>

My simple variable `window.myflag` that I use in option page, is reset/undefined and the value I store is only accessible from within the specific function calling it. In my content script, the window object retain its values instead.

---

<div class="post-metadata">

**Author:** ![jscher2000](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/jscher2000/32/28202_2.png) [@jscher2000](https://discourse.mozilla.org/u/jscher2000)\
**Post date:** [April 24, 2022, 8:48pm UTC](https://discourse.mozilla.org/t/cannot-access-window-object-in-option-page/95903/2 "2022-04-24T20:48:08Z")

</div>

I generally send a message from the options page to the background script for global values needed to lay out the page. And send changes back to the background script. Probably not the most efficient method, but…

---

<div class="post-metadata">

**Author:** ![elnath78](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/elnath78/32/23893_2.png) [@elnath78](https://discourse.mozilla.org/u/elnath78)\
**Post date:** [April 25, 2022, 11:16am UTC](https://discourse.mozilla.org/t/cannot-access-window-object-in-option-page/95903/3 "2022-04-25T11:16:47Z")

</div>

> [@jscher2000](#):
>
> I generally send a message from the options page to the background script for global values needed to lay out the page.

Since `storage` is available in the option page, I directly read it there.
