don't use window object

The window object doesn't exist in all JavaScript contexts, e.g. Web workers.