I believe this is the problem. In your first (working) example,
loadUrl("javascript:HtmlViewer.showHTML" + "('<html>'+document.forms[0].elements[’MYHiddenValue’].value+'</html>', 'blah');");
the second embedded parameter 'blah' does not have any internal quotes. However, in your first non-working example,
loadUrl("javascript:HtmlViewer.showHTML" + "('<html>'+document.forms[0].elements[’MYHiddenValue’].value+'</html>', 'document.forms[0].elements[’MYHiddenValue’].value');");
there is an embedded quote in a section of the parameter that should be evaluated. The following sub-string (found in both examples has a string ('') concatenated with code that evaluates to a string concatenated with another string, the closing HTML tag.
'<html>'+document.forms[0].elements[’MYHiddenValue’].value+'</html>'
In the non-working second example,
'document.forms[0].elements[’MYHiddenValue’].value'
You have a string that I believe just needs to be evaluated. JavaScript is seeing this as a string like as below, but this is not what you want.
'document.forms[0].elements[’
I believe if you remove the outer pair of single-quote marks in this non-working example, it will work, as the code will evaluate. If you need it to just be a string, then you need to escape the inner single-quote marks as in
'document.forms[0].elements[\'MYHiddenValue\'].value'