homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

manage dimensions of a frame
Some questions regarding this issue

Msg#: 4345973 posted 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,



Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved