Created
December 5, 2019 11:12
-
-
Save kyranjamie/e4df280ae54917e08c0cdb368018e549 to your computer and use it in GitHub Desktop.
Popup in browser, new tab when mobile/blocked
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
<!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