<button id="btn" onclick="doSomething()">Click me</button>Content-Security-Policy: script-src-attr directive
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
document.getElementById("btn").addEventListener("click", doSomething);