Skip to content Skip to sidebar Skip to footer

Sending Screen Resolution Via A Form

I've got it sending the user agent already: '/>Copy

and afterwards as a script

<script>
  document.getElementById('browser-resolution').value = screen.width + "x" + screen.height;
</script>

EDIT: added fiffle


Solution 2:

You will have to fill in the screen resolution via JavaScript and then send it. This is not a safe method, since anyone who wanted to could change the value in the hidden field... But it will work:

// Fill in forms with screen resolution (jQuery)
$('#screenWidth').val(screen.width);
$('#screenHeight').val(screen.height);

And simply use a couple of hidden fields:

<input type="hidden" name="screenWidth" id="screenWidth"/>
<input type="hidden" name="screenHeight" id="screenHeight"/>

Solution 3:

The previous example should work:

Javascript

document.getElementById('debug').value = screen.width + 'x' + screen.height;

Are you getting any errors? Which browser are you using? OS?


Solution 4:

As other people have said, the screen object works. Just saying "It doesn't work" doesn't help with finding the problem out. If you have jQuery correctly loaded, it will just work.

screen.width + "x" + screen.height

This returns "1280x1024" in my case.

See http://jsfiddle.net/KVQM4/ for an example of it working. If you can create something similar to show how it doesn't work, or give us a bit more information as to the error.


Post a Comment for "Sending Screen Resolution Via A Form"