Been searching around for an answer to this on MDC and in the source
but couldn't sort it.

It's easy to add an event to detect a page load, but how can I detect
when a page cannot be found?

When a page cannot be found, Firefox displays an error screen. I'd
like to have an event run when that screen is shown.

Likewise, I want to do the same when the user is in offline mode and
they try to access a page without an internet connection. Again,
Firefox throws up a error screen saying they are in offline mode and
cannot browse the web.

Any ideas?