Skip to content

Instantly share code, notes, and snippets.



Created Mar 6, 2019
What would you like to do?
random frontend patterns
// avoid popup blocker when you need async code when opening new tab\
// NOTE: the downside to this approach it the the user will see a blank page until the async method finished but instead of opening
// NOTE: to a blank page, you could probably have a redirect page that has animation or something
//first have a method that does the async functionality and get passed in the new tab window
const doRedirect = async (newWindow) => {
try {
const redirectUrl = await api.getRedirectUrl();
// this wonty be blocked because the window was open in the method directly tied to the event listener
newWindow.location.href = redirectUrl;
} catch (error) {
//do whatever error handling you need to
// then you have the method that you attach the event listener to
const newTabStart = () => {
const newWindow ='', '_blank');
// ------------------------------------------------------------------------------------------------------------------------------0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment