Small cross-browser hack in pure JS