April 28, 2000 - Page Watermarks
April 28, 2000|
Tips: April 2000
Yehuda Shiran, Ph.D.
waterMark()function and two statements:
makeLinkedImage(): creates the linked image of the watermark.
waterMark()repeatedly to check for changes in the window's or scroll area's size.
waterMark() function is based on checking four physical dimensions:
pageScrollTop. DOCJSLIB provides an appropriate function to get each of these dimension. Each dimension is saved in an "old" variable for comparison purposes during the next iteration. Any difference triggers repositioning of the image and refreshing of its Z index:
docjslib_setPosFromTop("docjslib", windowHeight + pageScrollTop - (imageHeight + bottomSpacer)); docjslib_setPosFromLeft("docjslib", windowWidth + pageScrollLeft - (imageWidth + rightSpacer)); var topZ = docjslib_findHighestZ(); docjslib_setZposition("docjslib", topZ);
Notice how the position of the top left corner of the image is computed. It depends on the window size (
windowWidth), how much is the page scrolled (
pageScrollLeft), a spacer between the image and the window (
rightSpacer), and the size of the image,
Also, notice that the highest
Z index is computed on every iteration, as
Z index of elements can change via the
setZposition() function of DOCJSLIB.
Learn more about our page watermarks and DOCJSLIB in Column 29, DOCJSLIB Version 3.0: Supporting Watermarks, and Column 33 DOCJSLIB Version 4.0: Scrollers, Watermarks, and Games.