Scrolling HTML Basics, Part I: Positioning A Scroll Box - Doc JavaScript
Positioning A Scroll Box
There are many ways to position a scroll box. You can position it in absolute coordinates, but the desired location may change because of an ad put at the top of the page, for example. In this column we use the table method. We place a dummy GIF at the top left and the bottom right corners of the table. We fill the table with some example headlines that will span the desired height of the scroll box. Here is the table in our page:
<TABLE ALIGN=RIGHT WIDTH=275>
<TR>
<TD ALIGN=LEFT><IMG NAME="pht" SRC="t.gif" ALT="" WIDTH=1 HEIGHT=1></TD>
</TR>
<TD>
<img class="bullet" src="bullet.gif">
<A CLASS="headline" HREF="/js/column29/"><B>[29] DOCJSLIB Version 3.0: Page
Watermarks</B></A>
<p>
<img class="bullet" src="bullet.gif">
<A CLASS="headline" HREF="/js/column28/"><B>[28] DOCJSLIB Version 2.0</B></A>
<p>
<img class="bullet" src="bullet.gif">
<A CLASS="headline" HREF="/js/column27/"><B>[27] DOCJSLIB Library, Part
I</B></A>
<p>
<img class="bullet" src="bullet.gif">
<A CLASS="headline" HREF="/js/column26/"><B>[26] JavaScript 1.3 Review,
Part II</B></A>
<p>
<img class="bullet" src="bullet.gif">
<A CLASS="headline" HREF="/js/column25/"><B>[25] JavaScript 1.3 Review,
Part I</B></A>
<p>
<img class="bullet" src="bullet.gif">
<A CLASS="headline" HREF="/js/column24/"><B>[24] Internet Explorer 5.0
Review, Part III</B></A>
<p>
</TD>
</TR>
<TR><TD ALIGN=RIGHT><IMG NAME="phb" SRC="t.gif" ALT="" WIDTH=1
HEIGHT=1></TD></TR>
</TABLE>
We then compute the coordinates of these GIFs in our scrolling box code:
bnrLft=document.images.pht.x;
bnrTop=document.images.pht.y;
bnrRit=document.images.phb.x;
bnrBot=document.images.phb.y;
bnrWid=bnrRit-bnrLft;
bnrHit=bnrBot-bnrTop;
and we use these coordinates to call the scroll box API:
scrollBox(bnrLft, bnrTop, bnrWid, bnrHit,'jscolumns3.html',50)
Produced by Yehuda Shiran and Tomer Shiran
Created: November 23, 1998
Revised: November 23, 1998
URL: https://www.webreference.com/js/column30/position