Account for document.body being absent.

This fixes a problem I've run into a lot where on reloading a page I get an exception here which breaks since I have debugging on uncaught errors turned on.