screen size detect - select CSS

V

VK

Finding the canvas size is actually pretty simple in most scenarios if
you care to read section 4.9 of the group FAQ.

Repeating your own words: "That is one perverse block of code you have
there". It might be useful 6-7 years ago with availWidth/availHeight
being a proprietary IE feature (as "screen" object itself for this
matter). There is no need of it now.

P.S. I have a fantastic DynLib library written in 1998 to use NN4/IE4
DOM features in one function call. Till now I fills my heart of proud
to see the most incompatible things working together :) - but I'm not
pushing these forcedly sick twisted workarounds on anyone as of the
year 2007, do I?
 
R

rf

VK said:
Why would not check JavaScript/DOM basics for the answer? But to save
your googling time: window.screen.availWidth and
window.screen.availHeight reports the pixel width and height of canvas
area of the browser in the maximized state: thus the area lesser
application window (window border, toolbars, scrollbars etc.)

No it does not. It reports the physical width of a (possibly one of many)
screen minus the width of a possible vertical windows task bar (for windows
operating systems, that is). Similar for availHeight (with a possible
horizontal widows task bar). They most certainly do *not* take the browsers
border, menus and toolbars into account. This is why they are properties of
the screen object (the physical screen), rather than a mythical "canvas"
object.
 
V

VK

No it does not. It reports the physical width of a (possibly one of many)
screen minus the width of a possible vertical windows task bar (for windows
operating systems, that is). Similar for availHeight (with a possible
horizontal widows task bar). They most certainly do *not* take the browsers
border, menus and toolbars into account.

How about reading producer's documentation? Just for fun of it it may
be useful. If you want to explain "what it must to be by my opinion"
instead of "what it is" then the discussion will be rather non-
productive and pointless.

P.S. Dual screens is a famous "spooky man" of this clj, together with
Lynx, Netscape 4.x, MyFirstUA 0.1 beta and blind-and-deaf user with
tong sensor manipulator for browsing. These fears are predominant over
a group of posters in this group, making a number of their posts to be
a reasoning on the subject "Why JavaScript should not be used" and
"Why any Web development is futile". As with any fear the best remedy
remains a good paid practice they may be lacking. Just like with the
surgery: it doesn't matter how many vise book one has read: in order
to stop the hand's tremor one needs N real operations and at least a
few unlucky patients on the cemetery.
:)
 
V

VK

VK said the following on 11/11/2007 3:35 AM:
Are you saying that you see availWidth and availHeight in the group FAQ?

No, right the opposite: I do _not_ see availWidth and availHeight in
the mentioned FAQ. Habla Inglese? :) Instead I see a convoluted code
of the time of the Browser Wars when availWidth and availHeight did
not exist anywhere ouside of IE.
 
R

rf

VK said:
How about reading producer's documentation? Just for fun of it it may
be useful. If you want to explain "what it must to be by my opinion"
instead of "what it is" then the discussion will be rather non-
productive and pointless.

How about doing some testing. Open a browser, maximise it, and then point it
to a page that alerts window.screen.availHeight and
window.screen.availWidth. Publish the resultant numbers here. Also publish
the size of your screen in pixels.

I don't have to read any "producer's documentation" whatever that is. I
simply note what the browser says, and it is *not* what you say.

<snip drivel>
 
V

VK

No it does not. It reports the physical width of a (possibly one of many)
screen minus the width of a possible vertical windows task bar (for windows
operating systems, that is). Similar for availHeight (with a possible
horizontal widows task bar). They most certainly do *not* take the browsers
border, menus and toolbars into account. This is why they are properties of
the screen object (the physical screen), rather than a mythical "canvas"
object.

Yes, you are right. I was too long on chromes I guess. Sorry to OP,
sorry to you for an excited style of the last posting, sorry to FAQ
maintainer. So the code at http://www.jibbering.com/faq/#FAQ4_9 is
useful if one needs to find out the current "canvas" dimensions.

Does it mean that there is no way to find the _maximum possible_
canvas dimensions for the current user?
If not then the OP's question does not have a doable answer.
 
D

dE|_

"VK" patiently told dE|_ when he said:
First considered for selecting a 2nd style sheet with appropriately sized
background image based on viewport detect.
This method rather than CSS stretch to avoid rubbery pixelated jpeg
stretching by the browser as it will be a sharp focused photo.

Principle; Entire picture does not have to show on a shrunk window, just
be
able to fill it when maximised, and prime central content visible when
window is at a 'typical' 75%.

After the above concept I just wondered briefly whether viewport detect -
meets - CSS was something done elsewhere.

Told not, thread cut.

There is one value which is too variable: that is the maximized
height. With numerous native and added (say Google bar) toolbars,
where each can be shown or hidden in most different combinations: you
may spend the rest of your life by making pixel-exact pictures for
each possible situation :) I would suggest to go for a small(?)
compromise by making right and bottom sides of your background
smoothly fading to some color. Based on the sample at
http://www.websitefoundry.co.uk/
that could be some variation of orange. By setting the background-
color to the same color you will avoid white bars on screen in any
given case. So CSS could be:

<style type="text/css">
body {
/* Default image for the most expected situation.
What is "most expected" is of course up to you
to decide. The image is faded from the right
and from the bottom to the bgcolor:
*/
background-image: url(1024x740.jpg);
background-repeat: no-repeat;
background-position: left top;
background-attachment: fixed; /* or not */
background-color: orange; /* or whatever else */
}
</style>

Now we have something even if JS is disabled. If it is not then you
may make some runtime fine-tune:

<script type="text/javascript">
/* A list of all available bg images
mapped by their width:
*/
var bgrImages = {
'1024' : '1024x740.jpg',
'1100' : 'X1xY1.jpg',
'1500' : 'X2xY2.jpg'
};

if ((window.screen)&&(window.screen.availWidth)) {
var w = window.screen.availWidth;
/* var h = window.screen.availHeight; */
if (bgrImages[w]) {
document.body.style.backgroundImage = 'url(' + bgrImages[w] + ')';
}
}
</script>

Blimey, thanks for all that, I'll go through it all when the hangover clears
off.

Looks like you triggered a few thoughts in others!

---dE|_---
 
D

Dr J R Stockton

In uk.net.web.authoring message said:
Finding the canvas size is actually pretty simple in most scenarios if
you care to read section 4.9 of the group FAQ.

The FAQ of this newsgroup has AFAICS no section 4.9. TBYW.
 
D

Dr J R Stockton

In uk.net.web.authoring message said:
Dr J R Stockton said the following on 11/11/2007 4:00 PM:



Then you need to learn to read plain English and how to find an FAQ.

No; but you need to pay more attention to the exact meaning, if any, of
"this" in the current context, and to where your article is actually
going.

Jim : Have you a URL for the most recent unwa FAQ?
 
A

AGw. (Usenet)

I have started looking into scripts for screen size detect with the
intention of using them to pick from a number of CSS style sheets tailored
to the size.

Is there a good reason why this is not so commonly done? IE am I wasting my
time?

I see further down this thread you have quite a specific thing you'd
like to do... but I'm going to ignore that!

Web developers are seldom as smart as they think they are. Whenever
they try to do something clever that takes into account all variables,
they mess things up because there's some variable (if not more) that
they haven't thought of.

Potential problems with coding based on "size" include:
1. the user might not have their browser maximised
2. you don't know how much chrome the browser is using
3. you don't know if the user is currently displaying optional
components such as Firefox's sidebar
4. if the user is currently displaying optional components such as
Firefox's sidebar, you don't know how wide they've decided to have it
display
5. you don't know what text size the user has selected as their
default
6. you don't know if the user will change the size of their browser's
window *while visiting your site*
7. if the user is currently displaying optional components such as
Firefox's sidebar, you don't know if they're going to change its width
*while visiting your site*
8. you don't know if the user has JavaScript enabled
9. scrollbars are different widths in different browsers on the same
system
10. some users will have more than one screen
11. opening pages in the background can change the height available
for your site in Firefox because another row is needed for the extra
tabs
12. different platforms will affect the exact measurements of most of
the above items

I'm sure there are quite a few more that I've not thought of!
Unfortunately, you'd have to think of them all as well...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,177
Latest member
OrderGlucea
Top