no scrollbars in div (firefox)

J

juergen.riemer

Hi,

following code does not render scrollbars in firefox 1.5.x. Bug?
Workaround other than to innerHTML an absolute positioned element
after loading?


<html>
<body>
<div style='width:100px;height:100px;position:absolute;border:1px
solid black;overflow:auto'>
<div id='test' style="position:absolute;top:0px;left:30px">X</div>
</div>
<script>
onload = function(){
document.getElementById('test').style.left = "115px"
}
</script>
</body>
</html>
 
D

dd

following code does not render scrollbars in firefox 1.5.x. Bug?
Workaround other than to innerHTML an absolute positioned element
after loading?

That's what I do and it's reliably calculated the scrollbar size on
NS6,7,8,FF etc. Try this (which declares a global called
ScrollbarOffset):

window.onload=function(){
var outerdiv=document.createElement("div");
outerdiv.style.position="absolute";
outerdiv.style.top="0px";
outerdiv.style.left="0px";
outerdiv.style.width="50px";
outerdiv.style.height="50px";
outerdiv.style.overflow="hidden";
var innerdiv=document.createElement("div");
innerdiv.style.width="100%";
innerdiv.style.height="60px";
outerdiv.appendChild(innerdiv);
document.body.appendChild(outerdiv);
var noscrolloffset=innerdiv.offsetWidth;
outerdiv.style.overflow="auto";
var withscrolloffset=innerdiv.offsetWidth;
document.body.removeChild(document.body.lastChild);
ScrollbarOffset=noscrolloffset-withscrolloffset;
}
 
D

dd

NS6,7,8,FF etc. Try this (which declares a global called
ScrollbarOffset):

window.onload=function(){
var outerdiv=document.createElement("div");
outerdiv.style.position="absolute";
outerdiv.style.top="0px";
outerdiv.style.left="0px";
outerdiv.style.width="50px";
outerdiv.style.height="50px";
outerdiv.style.overflow="hidden";
var innerdiv=document.createElement("div");
innerdiv.style.width="100%";
innerdiv.style.height="60px";
outerdiv.appendChild(innerdiv);
document.body.appendChild(outerdiv);
var noscrolloffset=innerdiv.offsetWidth;
outerdiv.style.overflow="auto";
var withscrolloffset=innerdiv.offsetWidth;
document.body.removeChild(document.body.lastChild);
ScrollbarOffset=noscrolloffset-withscrolloffset;

FYI to the people who manage the FAQ at jibbering.com, re: item # 4.9
- that example code isn't taking the scrollbars for Gecko browsers
into account. This code above calculates the scrollbar size (which
varies from 15 to 19 pixels).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top