Can JavaScript catch a 404 error triggered by a page’s object?
The specific problem I’m facing is with a buggy Flash application that I don’t control. When it fails, I’d like t开发者_运维知识库o display alternate content.
The page which contains the Flash content has loaded and it’s clearly the Flash app making the request that results in this message in the debug console:
Failed to load resource: the server responded with a status of 404 (Not Found) /path/filename
So I'm wondering if there’s some way to detect that with some JavaScript that loads with the page that contains the Flash object.
I tried window.onerror, but that’s not detecting it.
If it's a request being made from within Flash, I'd say no. Only browser add-ons (such as Firebug) can monitor all requests.
The only way to detect that with JS is to have JS on your 404 page. You only get the 404 when the specified content can't be vended, so no JS would be vended either.
精彩评论