Problemer med DragBar
Hej!Jeg sidder med noget javascript kode, som jeg har fundet på nettet. Denne kode laver blot 2 div tags hvori man kan indsætte teksten. I midten af disse divs har man en dragbar som man kan hive op og ned. Javascript koden bag side er lavet således at når man hiver dragbaren opad, så bliver øvre div tag mindre, og det omvendte skulle også gøre det samme, dvs. når man hiver dragbaren nedad, så bør nedre div tag også blive mindre, men det gør den ikke. I stedet bliver højden på nedre div tag ved med at være den samme. Denne div bliver blot forskudt nedad.
Det jeg ønsker er at få denne nedre div tag til at blive mindre, når man trækker dragbaren nedad, ganske som den øvre div tag gør.
Håber at det er til at forstå.
Koden går således:
<SCRIPT language="JScript">
var currentDragBar;
var visibleDragBar;
var starty;
var offsety;
var miny;
var maxy;
var barwidth;
var istable=0;
var element;
function dragStart() {
element = document.getElementById("outerDiv");
starty = event.y;
currentDragBar=event.srcElement;
currentDragBar.setCapture();
if (!visibleDragBar) {
visibleDragBar=window.createPopup();
var vdbbody = visibleDragBar.document.body;
vdbbody.innerHTML="";
vdbbody.style.background="window";
}
var row;
row = currentDragBar;
above= currentDragBar.previousSibling;
while (above && above.nodeType != 1)
above=above.previousSibling;
below=currentDragBar.nextSibling;
while (below && below.nodeType != 1)
below=below.nextSibling;
offsety= currentDragBar.offsetTop-starty;
barwidth = element.offsetWidth;
var parent = element;
var realleft=0;
visibleDragBar.show(0, offsety+starty, barwidth, 10, element);
miny=above.offsetTop;
maxy=below.offsetTop+below.offsetHeight-row.offsetHeight;
if (above.minHeight) {
if (miny < above.offsetTop+parseInt(above.minHeight))
miny=above.offsetTop+parseInt(above.minHeight);
}
if (above.maxHeight) {
if (maxy > above.offsetTop+parseInt(above.maxHeight))
maxy=above.offsetTop+parseInt(above.maxHeight);
}
if (below.minHeight) {
if (maxy > below.offsetTop+below.offsetHeight-row.offsetHeight-parseInt(below.minHeight))
maxy=below.offsetTop+below.offsetHeight-row.offsetHeight-parseInt(below.minHeight);
}
if (below.maxHeight) {
if (miny < below.offsetTop+below.offsetHeight-row.offsetHeight-parseInt(below.maxHeight))
miny=below.offsetTop+below.offsetHeight-row.offsetHeight-parseInt(below.maxHeight);
}
}
function dragGo() {
if (!currentDragBar)
return;
var newy = offsety+event.y;
if (newy < miny)
newy=miny;
if (newy > maxy)
newy=maxy;
visibleDragBar.show(0, newy, barwidth, 10, element);
}
function dragStop() {
visibleDragBar.hide();
if (currentDragBar) {
var tmpDragBar = currentDragBar;
currentDragBar=null;
tmpDragBar.releaseCapture();
var maxh
maxh = parseInt(document.getElementById("outerDiv").style.height);
var newy = offsety+event.y;
var bundHeight;
bundHeight = maxh - newy
document.getElementById("Top").style.height = newy;
document.getElementById("Bund").style.height = bundHeight;
}
}
function initControl()
{
var element = document.getElementById("outerDiv")
element.style.overflow="auto";
var i;
var child=element.children[i];
var divider = document.getElementById("hrThing");
divider.style.cursor="row-resize";
divider.style.cursor="n-resize";
divider.style.height="5px";
divider.style.overflow="hidden";
divider.style.width="100%";
divider.style.borderStyle="outset";
divider.style.background="threedface";
divider.onmousedown=dragStart;
divider.onmousemove=dragGo;
divider.onmouseup=dragStop;
divider.onlosecapture=dragStop;
divider.setAttribute("UNSELECTABLE", true);
resizercalc();
}
function resizercalc()
{
var lastChild = document.getElementById("hrThing");
var leftover = document.getElementById("Bund").clientHeight;
}
</SCRIPT>
<div id="outerDiv" STYLE="border:1 solid black;">
<div id="Top" STYLE="border:1 solid black; width:100%; height:250px; background-color:#CCCCCC; overflow-y:scroll;">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
<br>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</br>
<br>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</br>
<br>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</br>
<br>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</br>
</div>
<div id="hrThing" STYLE="border:1 solid black;height:4px;background-color:black;"></div>
<div id="Bund" STYLE="border:1 solid black; width:100%; height:250px; background-color:#CCCCCC; overflow-y:scroll;">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
<br>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</br>
<br>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</br>
<br>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</br>
<br>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</br>
</div>
</div>
<SCRIPT language="javascript">initControl();</SCRIPT>
