Hare-Brained Ideas

November 21, 2005

The last three sites I developed were CSS-based (the one I'm currently working on, works best as tables -- I don't have the time to warp CSS to that layout). I did what I was supposed to do and left the meat of the page at the top: Only the company logo preceded the content; the navigation and other things came after.

There's a problem when things error out, though. The page looks really odd, since things like the navigation bar don't even draw (the script stops to barf before it gets that far, so the page doesn't know it's supposed to exist). Let's say my page layout is (roughly) this:

<body>
<div id="content">(Page stuff)</div>
<div id="navigation">(Links)</div>
</body>

So let's say my nav bar is at the top of the page, with a nice blue background. If as part of teh page stuff I do some server-side scripting, I may get an error message partway through:

<body>
<div id="content">ASP error '8000809a':
You suck.

Note that the page never made it to the end of the line, so my nav bar doesn't exist. When the page is styled, my blue bar is non-existant, and the page looks even worse that it would with just the error.

The solution, of course, is to not write error-inducing code. But since I'm only human that's not 100% guaranteed. I could always pull the on error resume next rabbit out of my hat, but that makes debugging a bitch: "The page didn't do anything!" "Well, what did you do?" "I forget." So of course I can't find the problem to fix it.

What would be nice would be something like the function templates (or whatever they're called) that C++ uses. That way I could "hint" to the browser that I'm going to be using some of the things I set up in the style sheet. Then if my code looked like this:

<html>
<head>
<template>
<!--
body {
#content
#navigation
}
-->
</template>
</head>
<body>
<div id="content">ASP error '8000809a':
You suck.

It wouldn't matter that the execution ended, because the page would "know" to drop the nav bar into place and at least fill in the look, even if the actual contents aren't there. The page would still be brokwn, but at least it wouldn't look half-done.

November 18, 2005November 24, 2005