[San-Diego-pm] Question

Al Tobey tobert at gmail.com
Mon Oct 20 19:40:09 PDT 2008


On Mon, Oct 20, 2008 at 7:26 PM, Joel Fentin <joel at fentin.com> 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?

Just add a hidden input field to the form before submit in pre-ajax style:

// not tested, probably has errors ... not robust at all (for
instance, doesn't handle multiple forms in a page)
var windowSize = document.createElement("input");
windowSize.setAttribute("type", "hidden");
windowSize.setAttribute("name", "window_size");
windowSize.setAttribute("id", "window_size");
windowSize.setAttribute("value", window.width + "x" + window.height);
document.getElementsByTagName()[0].appendChild(windowSize);

Or something like that ...

>
>
> --
> Joel Fentin       tel: 760-749-8863
> Email:            http://fentin.com/me/ContactMe.html
> Biz Website:      http://fentin.com
> Personal Website: http://fentin.com/me
> _______________________________________________
> San-Diego-pm mailing list
> San-Diego-pm at pm.org
> http://mail.pm.org/mailman/listinfo/san-diego-pm
>


More information about the San-Diego-pm mailing list