Supressing JavaScript errors in SharePoint sites when all else fails

In SharePoint sites that have custom templates if you do not want to re-write the whole page you end up substituing certain elements for your nice looking design. In some cases elements that you remove or do not use may be referenced by JavaScript and removing these can cause errors on the page in the browser that you cannot resolve. I had the issue on a project I was running and I found a solution that supresses the errors by turning off JavaScript error reporting on the page. I wouldn't recommend doing this site wide but on certain pages where nothing else works insert the following at the top of  the page.
<SCRIPT language="JavaScript">
<!--function silentErrorHandler() {return true;}window.onerror=silentErrorHandler;//-->