View Full Version : Screen Resolution and Typecasting

07-04-2007, 07:26 AM
I have created my own image resize function i will be using too, well, resize images placed inside div's based on the resolution of ones monitor. The only way i have found to grab the resolution is too use javascript screen.width ect.

The javascript method returns a string and i cannot manipulate that value at all, even after typecasting as it just sets to blank.

Pretty much all im asking is it possible to convert the data taken from the javascript values and make them numerical so i can perform addition, subtraction or anything on them.

07-04-2007, 10:21 AM
You can have a javascript that grabs the screen width and height and constructs a "get" string from it, then reloads the page.

if (!isset($_GET['sWidth'])) {
sWidth = window.innerWidth != null? window.innerWidth :
document.documentElement && document.documentElement.clientWidth ?
document.documentElement.clientWidth : document.body != null ?
document.body.clientWidth : null;
<p>Screen width = <?php echo $_GET['sWidth'] ?> </p>

You can also post the variables using hidden form fields.



07-04-2007, 01:34 PM
Thankyou for your response, i decided i would like to get the actual Div size instead of screen size. This is working great as far as i can see. If you can see any problems please let me know.

link: http://brods.devolvedguild.com/onetwotree

The middle content Div is the one with the image resize function grabbing the div width from the URL and altering the image included.

Thanks again

07-04-2007, 03:07 PM
I can see an overflow problem on firefox