Entry
How do I get NN4 to show a scrollbar if layer content extends beyond original document length?
Mar 31st, 2000 12:01
Martin Honnen, Radu Ban
NN4 is not re-adjusting the scrollbar when you dynamically expand
layers/positioned elements or move them beyond the original document
length.
There are two way to solve that:
1) You need to reserve space in advance for your longest
layers/deepest positioned layer using the (NN only in IE ignored)
SPACER
element e.g.
<SPACER TYPE="block" WIDTH="800" HEIGHT="600">
</BODY>
at the end of the page will make your page 600 pixels longer to reserve
space for layers which later expand or move down the page.
The disadvantage is that the scrollbars are then directly visible
without content being there to scroll to but currently you have to live
with that if you want your layers to show up.
2) It is actually possible to set
document.width
document.height
to accomodate for the layer and then the scrollbars are shown as needed.
Thus if you set
document.height =
layerRef.pageY + layerRef.clip.height;
for your lowest layer and
document.width =
layerRef.pageX + layerRef.clip.width;
for your most right layer you get scrollbars as needed.
The following is an example that demonstrates adjusting the
document.height:
<HTML>
<HEAD>
<SCRIPT>
var colors = ['orange', 'lime', 'blue', 'red', 'yellow'];
var c = 0;
function newLayer () {
var l = new Layer(200);
l.clip.height = 50;
l.bgColor = colors[c];
c = ++c % colors.length;
l.document.open();
l.document.write(
'<SPAN STYLE="color: white;">JavaScript.FAQTs.com<\/A>');
l.document.close();
l.top =
document.height < window.innerHeight ?
window.innerHeight : document.height;
l.visibility = 'show';
document.height = l.pageY + l.clip.height;
}
</SCRIPT>
</HEAD>
<BODY>
<A HREF="javascript: newLayer(); void 0">
new Layer
</A>
</BODY>
</HTML>