-
-
Save Trikolon/531597cf73d88b23ae604e12a928aafc to your computer and use it in GitHub Desktop.
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
<html> | |
<head> | |
<meta charset='utf-8'> | |
<meta http-equiv='X-UA-Compatible' content='IE=edge'> | |
<title>requestStorageAccess Frame</title> | |
<meta name='viewport' content='width=device-width, initial-scale=1'> | |
</head> | |
<body> | |
<button id="btn">requestStorageAccess</button> | |
<button id="btn2">Open Window</button> | |
<script> | |
function openWindow() { | |
window.open("https://example.com"); | |
} | |
document.getElementById("btn2").addEventListener("click", () => { | |
// Works | |
openWindow(); | |
}) | |
document.getElementById("btn").addEventListener("click", () => { | |
// Has user activation | |
document.requestStorageAccess().then(() => { | |
// User activation lost? | |
openWindow(); | |
}) | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment