# $w('Page') issues with Chrome et al

**URL:** <https://forum.wixstudio.com/t/w-page-issues-with-chrome-et-al/8287>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [March 9, 2021, 12:39am UTC](https://forum.wixstudio.com/t/w-page-issues-with-chrome-et-al/8287 "2021-03-09T00:39:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rodneyelliott](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@rodneyelliott](https://forum.wixstudio.com/u/rodneyelliott)\
**Post date:** [March 9, 2021, 12:39am UTC](https://forum.wixstudio.com/t/w-page-issues-with-chrome-et-al/8287/1 "2021-03-09T00:39:13Z")

</div>

I have code that gathers page elements by type - something like:

```javascript
// Create arrays of page element IDs.
let pageElementIds = $w('Page').children;

function findImageElementIds(element) {
  let regex = /imTag/;
  return regex.test(element.id);
}
  
let imageElementIds = pageElementIds.filter(findImageElementIds);

```

This code works perfectly fine in Firefox, yet when I try to run it in Chrome, Edge, or Vivaldi, I get a series of console errors that seem to boil down to:

```javascript
Typerrror: Cannot read property 'filter' of undefined. 

```

Given that the array filter method is supported by all browsers, I can only assume that the issue lies with the way that $w(‘Page’) is being interpreted. Can anyone shed light on what might be going on here? The fact the code works perfectly in Firefox but none of the other browsers really has me confused.

---

<div class="post-metadata">

**Author:** ![rodneyelliott](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@rodneyelliott](https://forum.wixstudio.com/u/rodneyelliott)\
**Post date:** [March 9, 2021, 5:20pm UTC](https://forum.wixstudio.com/t/w-page-issues-with-chrome-et-al/8287/2 "2021-03-09T17:20:53Z")

</div>

Anyone? I will make it even simpler:

```javascript
let documentElementIds = $w("Document").children;
console.log(documentElementIds);

let pageElementIds = $w('#page1').children;
console.log(pageElementIds);

```

Why does this code produce the following errors in Chrome but not Firefox?

 ![](https://us1.discourse-cdn.com/wix/original/3X/3/d/3d77335b2fe60c32238be43d8a31d2e7629eb570.png)

Is there another way to compile an array of specific page elements that does not use the obviously broken code above?

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [March 9, 2021, 5:36pm UTC](https://forum.wixstudio.com/t/w-page-issues-with-chrome-et-al/8287/3 "2021-03-09T17:36:25Z")

</div>

Have you put it inside $w.onReady() ?

---

<div class="post-metadata">

**Author:** ![rodneyelliott](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@rodneyelliott](https://forum.wixstudio.com/u/rodneyelliott)\
**Post date:** [March 9, 2021, 6:48pm UTC](https://forum.wixstudio.com/t/w-page-issues-with-chrome-et-al/8287/4 "2021-03-09T18:48:07Z")

</div>

Aw darn it - and I remember reading somewhere that you were supposed to put all code that uses $w() inside onReady too. Thanks very much J.D.

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [March 9, 2021, 8:32pm UTC](https://forum.wixstudio.com/t/w-page-issues-with-chrome-et-al/8287/5 "2021-03-09T20:32:38Z")

</div>

You’re welcome.

BTW.  
You can have code outside the $w.onReady() if it doesn’t contain $w or if it is in the exported event handler that you set via the property panel.
