Keeping your head nice and tidy

Jake Howlett, 5 April 2001

Category: Quick Tips; Keywords: head html

This is one of those little things that, until you know about it, you never realise you miss. Then, when you find out, end up using it all the time.

In Domino Designer when you want to add things inside the <head> tag you do so in the "HTML Head Content" section or in the $$HTMLHead field if still using 4.6.

The problem with this is that whatever you put in there gets sent to the browser as one long line of text. If you are like me and like to keep everything tidy and nicely laid out (even if it doesn't really matter) then this is a pain.

The beauty of the "HTML Head Content" is that you can use formulas in it. This is what got me wondering what happens when you put @NewLine in there. Well, what do you know, it tells Domino to break it up in to separate lines. This way you can format the header of you domino generated page as you would any other page.

Here is an example HTML Head Content:

"<script type=\"text/javascript\" src=\"/" + DBPath + "/rsrc/JavaScripts/$file/global.js\"></script>" + @NewLine + @NewLine +
"<script>" + @NewLine +
"<!-- " + @NewLine +
" var isDocBeingEdited = " + @If(@IsDocBeingEdited; "true;"; "false;") + @NewLine +
"// -->" + @NewLine +
"</script>" + @NewLine + @NewLine +
"<style>" + @NewLine +
"td { + @NewLine +
" font: normal 12px verdana; + @NewLine +
"}" + @NewLine +
"</style>"


The resulting HTML is then:

<script type="text/javascript" src="/dir/DBName.nsf/rsrc/JavaScripts/$file/global.js"></script>

<script>
<!--
var isDocBeingEdited = false;
// -->
</script>

<style>
td {
font: normal 12px verdana;
}
</style>

Rather than the less desirable effect of using no @NewLines:

<script type="text/javascript" src="/dir/DBName.nsf/rsrc/JavaScripts/$file/global.js"></script><script><!-- var isDocBeingEdited = false;// --></script><style>td { font: normal 12px verdana;}</style>

If you have gotten this far (the end) and are thinking you've wasted your time then I'm sorry. Otherwise I hope you enjoy making use of this little snippet.