6

As I was wondering about the multi-monitor/screen support of javascript i found the follwing stackexchange questions relevant for the topic:

Quite a few of the questions and answers revolve around the missing option of handling multiple screens with javascript. Security and technical reasons are named to account for the non-existence of such a feature.

On the other hand a few thousand views show that there is interest in the topic and people have tried work-arounds for many years.

So i second I want to automate that process so as soon as they load the first address, a second window automatically pops up on the second monitor and fullscreens itself. This is internal only and will be expected behaviour. from the webmasters.stackexchange question and i would like to know what needs to be done to get this feature?

E.g. would the HTML standard have to be changed see e.g. question from 2014 on code project - would the browser vendors have to do something? Would there be a need for a Javascript addition to e.g. What information can we access from the client? And what would be the actions to get a solution up and running?

And by the way - if you think this is off-topic how would I have to change my question so that it won't be closed. I am very serious about this - there is a need behind this that I have seen quite a few times already.

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
  • Just because it's a good question, doesn't mean that it is a good question for stackoverflow... – Jared Smith Jul 31 '19 at 17:08
  • On what stackexchange site would it then be a better fit? – Wolfgang Fahl Jul 31 '19 at 17:09
  • I found e.g. https://www.w3.org/2013/10/tv-workshop/papers/webtv4_submission_19.pdf – Wolfgang Fahl Jul 31 '19 at 17:44
  • I don't know that it's a good fit for any of the stacks... tc39 mailing list maybe? – Jared Smith Jul 31 '19 at 18:05
  • 1
    How about https://developers.google.com/web/updates/2018/04/present-web-pages-to-secondary-attached-displays – Wolfgang Fahl Jul 31 '19 at 18:15
  • That might be a good fit for your use case. – Jared Smith Jul 31 '19 at 18:31
  • 1
    @JaredSmith No, definitely not tc39 mailing list. They only care about features of the programming language. For requests of new web APIs, the WHATWG mailing lists or github repositories are the relevant places. – Bergi Jul 31 '19 at 19:12
  • @WolfgangFahl Looks like you found the solution :-) You might even want to post answers (but targeted on the OPs issue, not just copies of the same text) on all the questions you linked. – Bergi Jul 31 '19 at 19:15
  • Thx. I added an answer below some comments to the other questions and created https://stackoverflow.com/questions/tagged/presentation-api – Wolfgang Fahl Aug 01 '19 at 07:43
  • [This question](https://stackoverflow.com/questions/9550476/allowing-interaction-with-a-second-window-without-breaking-full-screen-in-the-fi) **is not about the presentation-api**. Even if the modern answer would be to use this API, a question *about* the API would be one asking how to use it. – Kaiido Aug 01 '19 at 07:52
  • yes indeed - the answer is about the presentation api and that's why I choose the tag for the question. It also sets the context for other lower visibility questions that i found today. – Wolfgang Fahl Aug 01 '19 at 07:54
  • No that's not how tags should be used. Back in the day jQuery was **the** thing, even though many answers would point to jQuery solution, answerers would not add the tag because one of the answer was using it. Even the current question is actually not about that API. – Kaiido Aug 01 '19 at 07:56

2 Answers2

5

Since Version 66 of Chrome it is possible to use the Presentation API There is a W3C Draft for it since 2019-04

The Example at

will work in Chrome 66+ and given an error message

ReferenceError: PresentationRequest is not defined (Your browser may not support this feature.)

for other browsers when clicking presentationRequest.start(). On Chrome 66+ a selection dialog appears

Example in english Example in german

and after picking the desired screen is used in full screen mode.

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
  • If you wish an English speaking version of the message: https://i.stack.imgur.com/UOG8O.png – Kaiido Aug 01 '19 at 07:49
  • In testing a new presentation defaults to fullscreen on my current device rather than a secondary attached display. So this isn't workable/reliable solution for me at present. – Lou Groshek Jun 21 '22 at 20:49
4

screen.isExtended is true if there are one or more additional displays.

window.getScreenDetails returns an object including an array of screens, with dimensions and position. The left value for your non-primary screen would be what to target to move a new window to that screen.

const doSetup = async () => {
  const screenDetails = await window.getScreenDetails()
  if (screen.isExtended && screenDetails.screens.length > 1) {
    const newChildWindow = window.open(
      url,
      'New Child Window',
      `popup,width=${800},height=${600},left=0,top=0`
    )
    newChildWindow.moveTo(screenDetails.screens[1].left, 0)
  }
}

Very thorough explanation here: https://web.dev/multi-screen-window-placement/

Lou Groshek
  • 718
  • 6
  • 23