Yes, You can use JavaScript.
Here's what I have in mind:
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
my $q = CGI->new;
print $q->header;
if ($q->param) {
my $W = $q->param('w');
my $H = $q->param('h');
print "Screen resolution is: $W X $H\n";
}
print <<HTML;
<html>
<head><title>Test Page</title>
<script language="javascript">
function GetRes() {
document.getElementById('w').value = screen.width;
document.getElementById('h').value = screen.height;
}
</script>
</head>
<body>
<form method="post" OnSubmit="GetRes();">
<input type="hidden" name="w" id="w" value="">
<input type="hidden" name="h" id="h" value="">
<input type="submit" value="Get Resolution">
</form>
</body>
</html>
HTML
But keep in mind that some people have Javascript disabled so you'll have to set a default W/H in case the hidden fields were empty.
And finally you'll have to do some verifications to make sure you are actually getting a valid resolution or whatever you want to call it. |