Computer Hope

Internet & Networking => Web design => Topic started by: Brock Jackson on December 16, 2004, 01:25:48 AM

Title: background images and the browser window
Post by: Brock Jackson on December 16, 2004, 01:25:48 AM
i was wondering if there is any way to get the window dimensions right as someone opens a window. maybe not, but i thought maybe i could use the
Code: [Select]
<body background="/bg.jpg" bgproperties="fixed" width="+width_of_window+" height="+height_of_window+"> so that the background picture will fill up the background without having to repeat it.
and if theres a way to achieve this affect, please let me know
Title: Re: background images and the browser window
Post by: Corrosive on December 16, 2004, 12:56:36 PM
Yes, you get Javascripts to do such a task (normally it's in the guise of a screen resolution detector) but I'm not liking you're plan of action.

Personally, I wouldn't do it because it sounds like a very tacky effect (unless you can somehow pull it off, which -no offence - is not likely). But if I did want to do it, I'd get a few background images to cope with the different resolutions, and use a bit of javascript or another scripting language to pick the appropriate file.

But that's just me. This site offers a script you might like (you may need to adapt it slightly):
http://www.pageresource.com/jscript/jscreen.htm

Alternatively, you could use CSS to centre the background image. Obviously you'll have the white background showing through at the edges but if it doesn't affect your design too much...
Title: Re: background images and the browser window
Post by: MMaverick on January 15, 2005, 04:54:45 AM
I wouldn't do that - to much work. What I would suggest is to make a new <DIV style="position:absolute"> layer which you make 100% wide and tall. Then put the picture in it <IMG> also 100% wide and tall. Finally you need to put the <DIV> layer to the background by setting the z-order to -1.

That's it. Works in IE, dunno about other browsers

I have this done in my website: http://bots.sscentral.com/mav
Title: Re: background images and the browser window
Post by: Flame on January 15, 2005, 08:15:48 PM
Read the post that you made on the other board..... It can't be possible...

[glb]Flame[/glb]
Title: Re: background images and the browser window
Post by: Corrosive on January 16, 2005, 12:20:01 PM
Actually Flame, I think BJ (If that's your real name, I sure feel sorry for you - you must have suffered years of torment in school for those initials ;) ) wants to get the screen resolution so that he can get a background picture - stored on the server locally - to fill the screen, not the desktop-background problem.