Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

manage dimensions of a frame

Some questions regarding this issue



8:30 pm on Jul 31, 2011 (gmt 0)

Hello everyone,

I'd like to ask some questions regarding the dimensions of a frame. The problem is that in browsers or computers with smaller pixel dimensions the backgroundimage of the frame overlaps and does not resize itself to only the viewable part

I got this javascript function that I found:

var winW = 630, winH = 460;
if (document.body && document.body.offsetWidth) {
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
if (document.compatMode=='CSS1Compat' &&
document.documentElement &&
document.documentElement.offsetWidth ) {
winW = document.documentElement.offsetWidth;
winH = document.documentElement.offsetHeight;
if (window.innerWidth && window.innerHeight) {
winW = window.innerWidth;
winH = window.innerHeight;

document.writeln('Window width = '+winW);
document.writeln('Window height = '+winH);

(Two last codelines are for viewing the result, they will be removed at alpha)

So I want to use this to resize my background image accordingly and to make it fit the frame. This with using the background-size tag in CSS.

Now there's one problem: I have no idea how to get the variables WinW and WinH usable in the HTML part of my code.

so how to insert the variables into the background-size tag?

Thnx in advance,


Featured Threads

Hot Threads This Week

Hot Threads This Month