Skip to content

Instantly share code, notes, and snippets.

@uupaa
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save uupaa/4d4c616055e19e3b8374 to your computer and use it in GitHub Desktop.

Select an option

Save uupaa/4d4c616055e19e3b8374 to your computer and use it in GitHub Desktop.
Block modal dialogs inside a sandboxed iframe. allow-modals

Block modal dialogs inside a sandboxed iframe

https://www.chromestatus.com/features/4747009953103872 は、Chrome 45 で追加された機能で、sandboxing された iframe の中における popup を抑止する。

具体的な用途は、不躾な広告をブロック など。

<!DOCTYPE html>
<meta http-equiv="Content-Security-Policy" content="sandbox allow-scripts">
<script>
alert("Yay!");
print();
confirm("Question?");
prompt("Question?");
</script>
</html>

上記の meta タグに allow-modals を追加すると alert, print, confirm, prompt が利用可能になる。

<meta http-equiv="Content-Security-Policy" content="sandbox allow-scripts allow-modals">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment