Detect Firefox and fix "window not defined" error