But first...Before showing a working sample page I'll admit the real classes have a little more code in them than I've shown so far, but only very little. For example, the HeadOut() function also contains this code, to optionally output a title if one is given.. // output title if one exists
if ( this.sTitle != null )
Out ( '<title>' + this.sTitle +'</title>' );
|
..and in common with many of the other classes, BodyOut contains this code: // output content if there is any
if ( this.Content != null )
this.Content ( );
|
A sample pageSo here is a sample page that uses my new classes. Not the same as your average asp page perhaps?.. <%@ Language=JavaScript %>
<!--#include file = "utils/PageClasses.asp"-->
<%
oPage.Head.sTitle = 'hello';
oPage.Body.Content = function ( )
{
Out ( '<p>Some body content goes here' );
Out ( '<h3>Close this window to continue..</h3>' );
}
oPage.Out ( );
%> |
Skipping the first two (hopefully obvious) lines, I set the title of the page, then create a function "on the fly" and assign it to the Body.Content member. Lastly, I call the oBody.Out function, which is the only line that does any work! See the result... In conclusionYou can see the entire source code for this article by clicking on the icon below. There are many more clever things you can do using the methods shown in this code - it certainly opened my eyes a little wider!  |