diff --git a/src/pyj/utils.pyj b/src/pyj/utils.pyj index ccaebbac8c..c6a6ca0636 100644 --- a/src/pyj/utils.pyj +++ b/src/pyj/utils.pyj @@ -242,7 +242,10 @@ def sandboxed_html(html, style, sandbox): final_html = f'
{html}' # prevent context menu on right click in iframe ans.addEventListener('load', def(ev): - ev.target.contentWindow.addEventListener('contextmenu', def(e): e.preventDefault();) + try: + ev.target.contentWindow.addEventListener('contextmenu', def(e): e.preventDefault();) + except: + pass ) ans.srcdoc = final_html return ans