It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Java Forum

Automatic Browser size

Automatic Browser size

Postby enemeth on Fri Apr 20, 2007 2:42 am

Can someone tell me if there is a way that i can use javascript in my codeing to automatically set the screen to be to the users display settings instead of having them use scroll bars?

Thank you ;)

Elaine
enemeth
 
Posts: 5
Joined: Thu Apr 19, 2007 3:25 am

Postby ggomez on Fri Apr 20, 2007 4:56 am

?¿?¿?¿?¿?¿

JSP???
ggomez
 
Posts: 45
Joined: Tue Apr 17, 2007 3:30 am
Location: !!!!!MéXiCo¡¡¡¡¡¡

Postby mwa103 on Fri Apr 20, 2007 1:59 pm

There is Javascript which will recognize the user's screen size, but I'm not sure if it works in all browsers.

Code: Select all
<script type="text/javascript">
       winW1=document.body.clientWidth;
            winW2=window.innerWidth;
            winH1=document.body.clientHeight;
            winH2=window.innerHeight;
            if(winW1 > 0)
                winW=winW1;
            else
            {
                if(winW2 > 0)
                    winW=winW2;
                else
                    winW=<default value>;
            }
            if(winH1 > 0)
                winH=winH1;
            else
            {
                if(winH2 > 0)
                    winH=winH2;
                else
                    winH=<default value>;
            }
</script>

This code must be located in the <body> section of the document to work in some browsers. Replace <default value> with whatever value you want to be the default (ex. I used 780 for width). If you want, there are ways to do this in css using percentages for width and height, but this could cause problems if you have images that are a set size. If you want to know how to do this in css look at the links I posted on this other thread:
http://www.devppl.com/forum/how-can-my-site-adjust-its-display-for-different-viewers-vt5680.html?highlight=

-Mike
mwa103
100+ Club
 
Posts: 206
Joined: Mon Mar 07, 2005 10:55 pm


Who is online

Users browsing this forum: No registered users and 0 guests