0

Is there a way to identify the number of screens using javascript or jquery?

We have an application which should not be mirrored on any screen, even the case hardware supporting more than one screen.

Thanks in advance.

siva
  • 63
  • 1
  • 16
  • Interesting question...what's the reason for such a requirement? Surely it's up to the user how and where they decide to place their browser on their desktop? – ADyson May 01 '19 at 06:38
  • create a single session in the backend with information from where its acessing from the headers.. and make sure the user must not enter the website from where else return error from backedn – Murtaza Hussain May 01 '19 at 06:42
  • Or are you really talking about being displayed on multiple **devices** at once? – ADyson May 01 '19 at 06:44
  • 3
    if the hardeware is duplicating output to multiple monitors, there's absolutely no way javascript can know about this - not even a native application would be able to tell, so a sandboxed interpreted language inside a heavily fortified environment like a web page in a browser has even less than zero chance of detecting this – Jaromanda X May 01 '19 at 06:48
  • @ADyson , we have developed a test taking environment, we would like to prevent the test taker from mirroring the screen and get prompted – siva May 01 '19 at 09:05
  • ok. So you want to stop someone else from looking at the test at the same time, you mean? If you restrict it to one screen, what will stop someone else from looking over their shoulder instead? Or them using an enormous TV screen as the monitor, which everyone can see? Ultimately, if someone wants to cheat, you can't really prevent them from doing so by using technology. It's up to the person taking the test to be honest. Or, if it's, for example, to use in schools in exam conditions, then it's up to the people running the test to make a secure environment in which the test is accessed. – ADyson May 01 '19 at 09:41
  • I don't think this is actually a technological problem, it's a cultural problem. P.S. I'd also say that implementing this as a web-based application does bring its own security and verification problems too. Obviously I don't know precisely all your functional and non-functional requirements, or the context, or who your customers are etc, but that is something you might want to give some thought to, as well. – ADyson May 01 '19 at 09:41

1 Answers1

1

If you're talking about purely browser-based detection, then you're probably out of luck. However, if the application is built around Electron, then you can use screen.getAllDisplays

const electron = require('electron')
const { app } = electron

app.on('ready', () => {
  const screens = electron.screen.getAllDisplays()

  if(screens.length > 1){
    // TODO: Do something when there's more than one display
  }
})
xprnio
  • 81
  • 4