[San-Diego-pm] Question

Chris Grau chris at chrisgrau.com
Mon Oct 20 19:34:45 PDT 2008


On Mon, Oct 20, 2008 at 07:26:51PM -0700, Joel Fentin wrote:
> The following is within a perl program on the server. My goal is to
> know the width of the surfer's screen so that I can make adjustments.
>
> my ($SWW);
> print qq|
> <script language="JavaScript">
>   var SW = screen.width;
> alert(SW);
> </script>|;
>
> # $SWW = SW;
>
> ===========================
>
> How do you get the javascript value into a perl variable?
>
> If SW is equal to 1280, how do I get that 1280 into $SWW?

Disclaimer #1: I haven't been a web developer for a few years.

When do you want this into a Perl variable?  On form submission?  That
would be easy enough, just have the JavaScript set a hidden input field.
If you want it at an arbitrary time, people use Ajax for that.

Disclaimer #2: I've never developed anything with Ajax.

http://search.cpan.org/~bpederse/CGI-Ajax-0.707/lib/CGI/Ajax.pm

There are probably a number of other modules that will do the job, but
that one looks like the simplest for a small script (like
CGI::Application versus Catalyst).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.pm.org/pipermail/san-diego-pm/attachments/20081020/20961179/attachment.bin>


More information about the San-Diego-pm mailing list