lucy24 - 2:53 am on Jul 31, 2013 (gmt 0)
with trial and error found it would work on any browser if there was no doc-type declaration
In other words: the code as written works only in "quirks" mode, so there is something non-compliant about it-- or, more likely, in the HTML it generates. Browsers will generally recognize HTML 5 features even if the dtd says HTML 4, so that shouldn't be the problem.
You'll need to fine-tooth-comb the code. Break it down into small bits, or comment-out most of it. You'll find some particular point where it stops working as intended. Once you've isolated the issue, you can work on fixing it. And you'll end up with better code.