...

View Full Version : Screen Resolution and Typecasting



Serex
07-04-2007, 06: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.

2reikis
07-04-2007, 09: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.


<?php
if (!isset($_GET['sWidth'])) {
?>
<script>
sWidth = window.innerWidth != null? window.innerWidth :
document.documentElement && document.documentElement.clientWidth ?
document.documentElement.clientWidth : document.body != null ?
document.body.clientWidth : null;
document.location.replace(document.URL+"?sWidth="+pageWidth());
</script>
<?php
}
else
{
?>
<p>Screen width = <?php echo $_GET['sWidth'] ?> </p>
<?php
}
?>

You can also post the variables using hidden form fields.

HTH

2reikis

Serex
07-04-2007, 12: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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum