So Mr Grumpy-o-Randy, what do you propose?
screen.clientWidth?screen.clientwidth:screen.width ;
height isn't particularly of my concern because width is more dependent
in a design unless its a horizontal website.
Randy Webb wrote:[color=blue]
> Seige said the following on 6/19/2006 1:40 PM:[color=green]
> > Ever had headache when you can't resize the background width using CSS:[/color]
>
> Nope, can't say that I have.
>[color=green]
> > body{
> > background: url(/images/bg.jpg) ;
> > background-width: 800px;
> > }
> >
> > It won't work, would it? Of course not, it's not even defined in CSS.
> > So, let's try to work it out using javascript
:
> >
> > There are two methods, first method you prepare plenty of different
> > width images, classifying them into 640, 800, 1024, 1280, 1600 and
> > whatever other sizes. Then you use javascript to detect screen width
> > and you're done. Easy but not exactly what I'm looking for.[/color]
>
> That one won't work reliably. screen width is irrelevant. Browser
> viewport might be of help though.
>[color=green]
> > Second method: create a layer (for the background image) to go beneath
> > the existing content and resizing the image according to the screen
> > width.[/color]
>
> Thats trivial and doesn't need JS to do it.
>[color=green]
> > bgimg = document.createElement("bgimg");
> > bgimg.src = "/images/bg.jpg";
> > st = {
> > position:"absolute",
> > zIndex:"-10",
> > width:screen.width,
> > top:"0",
> > left:"0"
> > }
> > for( s in st ){
> > img.style[s] = st[s];
> > }
> > document.body.appendChild(bgimg);
> >[/color]
>
> That doesn't make it as tall as the viewport, or anything else for that
> matter. And again, screen.width is irrelevant. A 2048 pixel wide image
> wouldn't go real well in my 600 pixel wide browser window.
>
> --
> Randy
> comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly
> Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/[/color]