Support foreach, pass in window and document.