|
||
| Inside Technique : Cool Rules : Server-side Generation We found the most reliable way to create rules was to generate them on the server. We recognized that the same createHR() function we execute on the client can execute unchanged on the server. Now, when the client receives the page, they just receive the table populated with the correct colors. Moving to the server only required modifying the single line of script that inserts the table into the page.
We changed the document.write() method to the server-side equivalent. The client-side rule is generated as follows:
The equivalent call to create this on the server with an ASP file is:
When it comes to using this code, we highly recommend the server solution over the client-side solution. When server-side scripting is not an option, another alternative is to use the function to generate the table string, and then copy the string directly into your document. In reality, inserting the generating table gives you the best performance, but also makes it more difficult to later customize the rule. GuidelinesBefore showing you the code, there are a couple guidelines you should keep in mind when building a rule:
On the last page is the actual source code. This code can run on either the client or server without modification. Page 1:Cool Rules © 1997-2000 InsideDHTML.com, LLC. All rights reserved. |