One of the nicest levels that I have seen had something along the lines of
<script> <!-- document.write(unescape("some horrible long string")); --></script>
<script> <!-- msgWindow=window.open("","displayWindow","menubar=yes"); msgWindow.document.write(unescape("some horrible long string")); --></script>
and then you can just view the new windows source. Finally when you are really stuck it is worth visiting some reference pages like those at Netscape or at Sun.