Small fix - use `window.document` instead of `document`

Accessing to `document` object throws an error in `node-webkit`. Now this library can be compatible with it.