Add onerror handling for img/video loading.

Argh. Good catch. This has been broken all along! The onload handler has to be set before the src element for images.