August 10, 2001 - Detecting A Page Completion
![]() |
August 10, 2001 Detecting A Page Completion Tips: August 2001
Yehuda Shiran, Ph.D.
|
DeviceRect and LayoutRect elements on the fly, we usually want to know when the rendered page is done. This is the motivation to add the OnLayoutComplete attribute to the LayoutRect element. The event LayoutComplete fires when the LayoutRect element stops rendering its content. The reason for this can be twofold: either the source is exhausted or the LayoutRect element is overflowed by a longer source.
Let's see how to use the event handler OnLayoutComplete. The function addFirstPage() assembles the document's first page from one LayoutRect element which is within a DeviceRect element. Notice the event handler ONLAYOUTCOMPLETE = 'onPageComplete()'. When the page is done rendering, we call the function onPageComplete() to continue rendering the remainder of the document. Try it. Here is the function addFirstPage():
function addFirstPage() {
newHTML = "<IE:DEVICERECT ID='devicerect1' MEDIA='print' CLASS='masterstyle'>";
newHTML += "<IE:LAYOUTRECT ID='layoutrect1' CONTENTSRC='010808.html'" +
"ONLAYOUTCOMPLETE='onPageComplete()' NEXTRECT='layoutrect2'" +
"CLASS='contentstyle'/>";
newHTML += "</IE:DEVICERECT>";
devicecontainer.insertAdjacentHTML("afterBegin", newHTML);
}
We'll cover the function onPageComplete() tomorrow. For more information on print templates, go to Column 89, Print Templates, Part I.



