Skip to content

Instantly share code, notes, and snippets.

@kyranjamie
Created December 5, 2019 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyranjamie/e4df280ae54917e08c0cdb368018e549 to your computer and use it in GitHub Desktop.
Save kyranjamie/e4df280ae54917e08c0cdb368018e549 to your computer and use it in GitHub Desktop.
Popup in browser, new tab when mobile/blocked
<!DOCTYPE html>
<html>
<head>
<title>Popup test</title>
</head>
<body>
<button class="js-button">Open popup</button>
</body>
<script>
const btn = document.querySelector('.js-button');
const width = 440;
const height = 584;
const options = [
'resizable=yes',
'scrollbars=yes',
'titlebar=yes',
`width=${width}`,
`height=${height}`,
`top=${(window.outerHeight / 2) - height / 2}`,
`left=${(window.outerWidth / 2) - width / 2}`
];
btn.addEventListener('click', () =>
window.open(
'http://127.0.0.1:8082/src/popup',
"_blank",
options.join(',')
)
)
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment