change document.open() to window.open()