Allow to specify window and document so you can target parent window