Created
May 24, 2016 23:47
-
-
Save jayphelps/dc8556e72caaf8b2ac5596afcf91498d to your computer and use it in GitHub Desktop.
async window.open()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onclick = () => { | |
// You MUST create the window on the same event | |
// tick/stack as the user-initiated event (e.g. click callback) | |
const googleWindow = window.open(); | |
// Do your async work | |
fakeAjax(response => { | |
// Change the URL of the window you created once you | |
// know what the full URL is! | |
googleWindow.location.replace(`https://google.com?q=${response}`); | |
}); | |
}; | |
function fakeAjax(callback) { | |
setTimeout(() => { | |
callback('example'); | |
}, 1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment