I use this code snippet to determine the client screen resolution and then register it
<input type="hidden" id="DFF63C7E-FB32-49AE-8ADA-3AB5C4834FB0" name="DFF63C7E-FB32-49AE-8ADA-3AB5C4834FB0"/>
<input type="hidden" id="565C07CF-0D37-41DE-B47D-A247E9BD231B" name="565C07CF-0D37-41DE-B47D-A247E9BD231B" />
<script type="text/javascript" language="javascript">
document.getElementById("DFF63C7E-FB32-49AE-8ADA-3AB5C4834FB0").value = screen.width;
document.getElementById("565C07CF-0D37-41DE-B47D-A247E9BD231B").value = screen.height;
</script>
It worked fine when testing in my local host, but what I learned from production logs was that the screen resolution was always 480x640. Does anyone know why this is happening?
And I did a few more digging and found that I can change the resolution of my primary monitor and regardless of whether I open my browser on the primary / secondary monitor, it always gives me the resolution of the primary monitor.
Is there a way to get screen resolution based on which monitor the browser opens?
And, obviously, the next question: if the resolution changes halfway (say, from the control panel) or moving the browser from one to the other, is there any way to detect / update it using JS?
source
share