# Bringing experiment to full screen after some loops

**URL:** <https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614>\
**Category:** Online experiments\
**Tags:** screen\
**Created:** [May 23, 2020, 6:19am UTC](https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614 "2020-05-23T06:19:45Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ylrbc](https://avatars.discourse-cdn.com/v4/letter/y/e47774/32.png) [@ylrbc](https://discourse.psychopy.org/u/ylrbc)\
**Post date:** [May 23, 2020, 6:19am UTC](https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614/1 "2020-05-23T06:19:45Z")

</div>

Hi,

I’m coding an experiment with PsychoJS and I had a problem with bringing experiment to full screen.

The experiment starts with

```auto
psychoJS.openWindow({
    fullscr: false,
    color: new util.Color('black'),
    units: 'norm'
});

```

I need to bring the window to full screen after a loop. So in the scheduler function of the full screen loop, I added

```auto
psychoJS.window.adjustScreenSize();

```

According to the source code this should be the function. But it doesn’t seem to work. There is also no log related to window size such as ‘Unable to go fullscreen’ or 'Resizing Window: ’ in console.

I have also tried having a dedicated scheduler just for this function. But it’s still the same.

Please let me know where I should put this function and if I missed something here.

Thanks!  
Yu Li

---

<div class="post-metadata">

**Author:** ![ylrbc](https://avatars.discourse-cdn.com/v4/letter/y/e47774/32.png) [@ylrbc](https://discourse.psychopy.org/u/ylrbc)\
**Post date:** [May 26, 2020, 4:25pm UTC](https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614/2 "2020-05-26T16:25:18Z")

</div>

It looks like this function should work since it is used by the core.gui API when a window is opened with “fullscr: true”:

```auto
// switch to full screen if requested:
self._psychoJS.window.adjustScreenSize();

```

Has anyone have experience calling this function in their experiment?

---

<div class="post-metadata">

**Author:** ![ylrbc](https://avatars.discourse-cdn.com/v4/letter/y/e47774/32.png) [@ylrbc](https://discourse.psychopy.org/u/ylrbc)\
**Post date:** [May 27, 2020, 2:20am UTC](https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614/3 "2020-05-27T02:20:04Z")

</div>

After digging around a bit more I found out that the “adjustScreenSize()” checks window.fullscr before bringing the window to full screen. Should have check this function first.

For anyone who wants to enable/disable fullscreen after initialization, window.fullscr needs to be set along with adjustScreenSize() or closeFullScreen().

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [May 27, 2020, 7:43am UTC](https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614/4 "2020-05-27T07:43:57Z")

</div>

Please could you give the exact JS code you used for JavaScript novices? I feel like I wouldn’t know what to type in the JS window without further research.

---

<div class="post-metadata">

**Author:** ![tajs](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@tajs](https://discourse.psychopy.org/u/tajs)\
**Post date:** [April 13, 2021, 8:49pm UTC](https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614/5 "2021-04-13T20:49:34Z")

</div>

This code snippet worked for me:

```auto
psychoJS.window.fullscr = true;
psychoJS.window.adjustScreenSize();

```

---

<div class="post-metadata">

**Author:** ![akoch](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akoch](https://discourse.psychopy.org/u/akoch)\
**Post date:** [February 1, 2022, 4:25pm UTC](https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614/6 "2022-02-01T16:25:10Z")

</div>

Hi,

This may seem like a basic question, but where did you input that code snippet to bring the experiment to full screen? At the beginning of the routine you want to be full screen, or outside it in some scheduler function?

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 1, 2022, 4:36pm UTC](https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614/7 "2022-02-01T16:36:26Z")

</div>

Try a Begin Routine tab in the routine you want to be full screen

---

<div class="post-metadata">

**Author:** ![akoch](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akoch](https://discourse.psychopy.org/u/akoch)\
**Post date:** [February 1, 2022, 4:50pm UTC](https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614/8 "2022-02-01T16:50:20Z")

</div>

Thanks for the prompt response! I tried that and got an error that says: “NameError: name ‘true’ is not defined.” It’s weird because I wrote the word true in lower case and without quotes. I just invited you to the repo on GitLab, if you are free to take a look! Or if you have other suggestions on how to combat this, I will try them out.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 1, 2022, 4:52pm UTC](https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614/9 "2022-02-01T16:52:04Z")

</div>

Did you write that code in a JS only code component? true (lower case) should be defined in JS unless you are defining it twice.

---

<div class="post-metadata">

**Author:** ![akoch](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akoch](https://discourse.psychopy.org/u/akoch)\
**Post date:** [February 1, 2022, 4:55pm UTC](https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614/10 "2022-02-01T16:55:39Z")

</div>

![Screen Shot 2022-02-01 at 11.55.01 AM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/5/d/5de0d98a1c04a292f8226a3eee34091c125c146c.jpeg)

Yes, I’ve uploaded to the JS only component.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 1, 2022, 5:47pm UTC](https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614/11 "2022-02-01T17:47:10Z")

</div>

I just ran it with no error messages (I got three recordings). Use Ctrl-Shift-R to ensure you are running the latest code.

---

<div class="post-metadata">

**Author:** ![akoch](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akoch](https://discourse.psychopy.org/u/akoch)\
**Post date:** [February 1, 2022, 6:03pm UTC](https://discourse.psychopy.org/t/bringing-experiment-to-full-screen-after-some-loops/13614/12 "2022-02-01T18:03:51Z")

</div>

Thank you very much for checking! I just ran it on a different Internet browser (I was trying to run it on Safari, but switched to Google Chrome and Mozilla Firefox) and it works now.
