Page 1 of 1
screen res from javascript to php
Posted: Wed Mar 05, 2003 5:07 am
by runelore
Hi, I need to find the end users screen resolution for a stats page I am creating. I know this has to be done using javascript. I can use javascript to store a variable with the information. My problem is how do I get that variable into php? (I don't wanna refresh the screen in any way). thank you.
Posted: Wed Mar 05, 2003 5:25 am
by twigletmac
If you don't want to refresh the page in any way then you can't get that variable from javascript to PHP.
Otherwise, you could store the value in a cookie and then access it later with PHP, or put the value in the URL and access it using $_GET or post it and access it using $_POST. PHP and JavaScript cannot talk to each other directly though since one is server-side and the other client-side.
Mac
Posted: Wed Mar 05, 2003 5:25 am
by patrikG
Make a either an inline-frame or a frameset with rows=100%,0. The 0 is the "invisible" frame where you can store data, submit it etc. etc.
So, just create a form in the invisible frame, have the values of the screen-res filled in, then autosubmit. nobody will see it (well...:p )
Posted: Wed Mar 05, 2003 5:29 am
by twigletmac
Oh yes, or put it in a frame (forgot about that, tend to avoid frames myself) - you do need to refresh something for PHP to get the info though.
Mac
Posted: Wed Mar 05, 2003 5:34 am
by runelore
Thank you very much, I hadn't thought of that... thanks.
Posted: Wed Mar 05, 2003 5:36 am
by runelore
is there any way to get the screen res other than javascript. This is because a lot fo the stuff we do is without frames. Thanks...
Posted: Wed Mar 05, 2003 5:42 am
by patrikG
Screen-res is client-side. In order for PHP to get that info you need to use one of the options above.
If you use an inline-frame and can be reasonably sure that people will use a browser which understands inline-frames, do that. It won't impact on any search-engine's indexing.
Posted: Wed Mar 05, 2003 5:42 am
by twigletmac
You have to use something client side to get the screen resolution - which is why PHP can't do it but JavaScript can.
Mac
Posted: Wed Mar 05, 2003 5:55 am
by runelore
Thank you all very much.. I appreciate all your help... thanks again.