window.onerror in Firefox and Chrome seems to discard the real error message/location and always pass "Script error.", "", 0 when the offending script is on a different domain than the page itself. I have a site with separate www and static subdomains for pages and css/js, which renders error logging rather useless. Is there any way to enable the proper logging of such errors?
window.onerror in Firefox and Chrome seems to discard the real error message/location and always
Share
The real solution is to use proper
try { ... } catch(e) { ... }blocks in all code. However, I understand that may not always be an option.If you don’t have control over these other scripts, your next best option would be to load them as strings via JSONP, then use
eval()(yes, I know eval is evil) to “inject” them into the current page. This way you’ll still get the benefits of using a static domain (no cookies, CDN option, additional concurrent requests, etc), but the JS will end up being on the page’s request domain.