Block modal dialogs in a sandboxed iframe Sample

Available in Chrome 46+ | View on GitHub | Browse Samples

From now on, sandboxed frames will block modal dialogs by default to prevent them from popping up confusing, modal messages to users. This includes the infamous window.alert(), window.confirm(), window.print() and window.prompt().

However if you really (really) want to allow modal dialogs inside a sandboxed frame, you can still add "allow-modals" to its "sandbox" attribute.

<!-- No sandbox there... Modal dialogs will pop up -->
<iframe id="red" src="iframe.html"></iframe>

<!-- Sandbox frame will execute javascript but block modal dialogs -->
<iframe id="green" src="iframe.html" sandbox="allow-scripts"></iframe>

<!-- Sandbox frame will execute javascript and show modal dialogs -->
<iframe id="blue" src="iframe.html"
        sandbox="allow-scripts allow-modals"></iframe>