Not sure, but I'll take a crack at this:
First, I'd use a class rather than an id for the dontprint directive like this:
.dontprint {
display: none;
}
Because then you can re-use that in multiple places in your HTML where you'd like items that don't print.
2) Then I would put the <div class='dontprint'> directly into the javascript code (in a document.write or what have you) so that that the div gets output along with the other output that the menu js produces. So instead of wrapping your script tag with the div, you're including the div in your javascript rendering.
Not sure if it'll work, but worth a try!