Well, it seems that you folks were able to break my little piece of script pretty darned thoroughly. The "No Documents Found" bit was entirely my fault. Pulling any old bit of script off of the ol' hard drive and posting it with only minimal testing is not a good idea. It worked in the project I was doing, but that's because I had "pinned" documents so there was always something in the view.
The problems with the script are twofold. First, if you create a WYSIWYG heading, Domino generates a DIV around the FONT tag soup it needs to render your semantically useless verbiage (sorry, folks, but unless you use an Hx tag to mark a heading, it ain't a heading). That wouldn't be so bad, except that it will eat the passthru DIV you created around the view by putting the heading's closing /DIV tag after your passthru. Easy to fix, you'd think -- just make sure there's at least one line of not-centred text between the heading DIV and the passthru, right?
Well, that does close the alignment DIV tag before the passthru DIV, but it creates a new problem. Domino may throw in an unclosed P tag, just for fun. Now, I have no problem with Domino rendering a line break with a paragraph. It might not be semantically correct when there is no actual paragraph content, but it's not a biggie, either. What burns my butt is the fact that the tag is never closed. That throws the whole document structure for a loop. The P will not be logically closed until its parent, Domino's FORM tag, is also closed.
There are three ways to try to handle this. The first is to futz around with the form in Designer until you can force Domino to render a BR instead of a P. A BR tag is not a container, so it won't interfere with stepping through the hierarchy in either direction. I'm not quite sure what the magic words are, or what face you have to make while doing it, but it CAN be done. Obviously, it's not particularly reliable, and the next developer to touch the form is going to break it. You can also try closing the P tag yourself, but this will get you no further -- eventually, someone is going to do something that changes the P to a BR. Or worse, they're going to try to get rid of the extra space between the heading and the view, closing off the DIV tag yet again.
The second is to expand the script yet again to cover all of the possible bases, searching every nook and cranny of the DOM until the view table, and only the view table, is finally found. You saw how big the original script was. Scanning the whole DOM tree until you find something that looks like it might be a view will make that little script just a little bit bigger. I'm not afraid of a little scripting (remember the library I keep talking about?), but I do resent having to write that much code to get around something that should never have been a problem in the first place.
No, folks, I am not whining about Domino's overall HTML rendering. While it can be improved somewhat (and Mark Vincenzes and team are working on it for Domino Next), it is very nearly impossible to create semantically-correct markup from purely visual formatting in a reliable way. A human being with good vision looking at the page can intuit the meaning of the text based on its formatting, but a machine can only do so much. What if your headings are smaller than the body text (a common-enough thing in trendy print publications)? There are some things we need to do ourselves if we want the end result to be meaningful and accessible. But there are a few little bugs that need to be squashed. They might not get the fixes into the current code streams (6.5.x & 7.x), but we can try to make sure that they are gone for Domino Next (no fixed number has been announced yet, but it has been stated that the number will be somewhere between 7.9 and 8.1).
In any case, the script as it now stands has been through the wringer. It'll find the view table if it's there and at least comes somewhere after the viewPanel DIV tag, as long as you don't put another table between the view and the div tag. If there's a "No Documents Found", it fails gracefully -- again, as long as you don't put an H2 tag into the middle of the actual viewPanel DIV AND use a centred, justified, or right-aligned WYSIWYG heading right above the passthru. (I'm only looking for the H2, since I can't predict the language of the message.) I've done everything I can to mangle the $$ViewTemplate and the view, and it seems to be bulletproof. Well, at least until one of you folks tries to use it, that is -- somebody's going to have done something I never would have though of trying, and that will probably result in Domino rendering the table cells outside of the table tag or something. Can you ever really win at this game?