Forum Moderators: not2easy

Message Too Old, No Replies

How do I detect if a style sheet exists on a page.

I need to dynamically stretch an inner style sheet

         

Nicky

4:13 am on Mar 2, 2004 (gmt 0)

10+ Year Member



I have a css container "container" within that - on some pages only - I have a "norm" container. The problem is sometimes the "norm" sheet data that is too long of the "container" sheet and so it flows over the footer.

I'm using the "list apart" footer hack to fix the problem and it works on pages that don't have the "norm" sheet.

What I need is to edit this code :

code:

function setFooter() {
if (document.getElementById) {
var windowHeight = getWindowHeight();
if (windowHeight > 0) {
var contentHeight = document.getElementById('container').offsetHeight;
var footerElement = document.getElementById('footer');
var footerHeight = footerElement.offsetHeight;
if (windowHeight - (contentHeight + footerHeight) >= 0) {
footerElement.style.top=(windowHeight-(contentHeight+footerHeight))+'px';
}
else {
footerElement.style.position='static';
}
}
}
}

to test the "norm" sheet height - easy to do , just add this :
var normheight = document.getElementById('norm').offsetHeight;
etc ..

but if the "norm" sheet does not exist on the page then IE errors. How can I test if the norm sheet exists or not? I think I need something like (isobject)?

Any hints?

Nicky

8:07 am on Mar 2, 2004 (gmt 0)

10+ Year Member



I got it working on all pages but if the page has a table then it stretches below the footer..... it seems to not detect the container is longer if it has a table in it.

This is the code for the fix

unction setFooter() {
if (document.getElementById) {
var windowHeight = getWindowHeight();
if (windowHeight > 0) {
if (document.getElementById('norm')) {
var cHeight = document.getElementById('norm').offsetHeight;
} else {
var cHeight = document.getElementById('container').offsetHeight;
}
var footerElement = document.getElementById('footer');
var footerHeight = footerElement.offsetHeight;
if (windowHeight - (cHeight + footerHeight) >= 0) {
footerElement.style.top = (windowHeight - (cHeight+footerHeight)) + 'px';
}
else {
footerElement.style.position = 'static';
}
}
}
}

So does anyone know how to get it to detect the page is longer if it contains tables?