|
August 13, 2001 Turning Off Events Tips: August 2001
Yehuda Shiran, Ph.D.
|
|
Defensive programming is a philosophy you should adopt when writing your JavaScript scripts. According to this philosophy, you should never rely on the system to do stuff for you. Instead, you should set your variables yourself, either before or after the relevant event. Let's see an example. Here is the function onPageComplete() that is used to create a dynamic print template:
Try it. Works perfectly. Now, let's omit the first line inside the if statement. We'll get the new onPageComplete() function:
Try it. You should get one blank page at the end. The reason for this is an extra event of onlayoutcomplete of the previous page that we have already printed. The first line of onPageComplete() sets it to null before printing the next page:
For more information on print templates, go to Column 89, Print Templates, Part I.
People who read this tip also read these tips: Look for similar tips by subject: |