If this line:
document.getElementById('resolutionfield').value = screenres;
is executed too early before the resolutionfield
DOM element has been parsed and thus is present in the DOM, then this will cause an error and stop execution of your script. That's because:
document.getElementById('resolutionfield')
will be null
and then when you try to reference the .value
property, it will not work and will generate the error Uncaught TypeError: Cannot set property 'value' of null
which you can see in the browser's error console or debug console.