From 909654fa39b1434dfceba8a2db8e75c7f9331603 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 3 Nov 2023 12:55:43 +0530 Subject: [PATCH] Content server: Book details: Open links in comments fields in the same window rather than a new window --- src/pyj/book_list/book_details.pyj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pyj/book_list/book_details.pyj b/src/pyj/book_list/book_details.pyj index 4c6cf35f49..95b4c7188c 100644 --- a/src/pyj/book_list/book_details.pyj +++ b/src/pyj/book_list/book_details.pyj @@ -124,7 +124,7 @@ def adjust_iframe_height(iframe): def setup_iframe(iframe): de = adjust_iframe_height(iframe) for a in de.querySelectorAll('a[href]'): - a.setAttribute('target', '_blank') + a.setAttribute('target', '_parent') def forward_touch_events(ev): container = window.top.document.getElementById(render_book.container_id) @@ -158,9 +158,9 @@ def adjusting_sandboxed_html(html, extra_css): css = f'\n\n:root {{ color-scheme: {color_scheme()} }}\n\nhtml, body {{ overflow: hidden; color: rgba({color[0]}, {color[1]}, {color[2]}, {color[3]}) }}' if extra_css: css += '\n\n' + extra_css - # allow-same-origin is needed for resizing and allow-popups is needed for - # target="_blank" - ans = sandboxed_html(html, css, 'allow-same-origin allow-popups allow-popups-to-escape-sandbox') + # allow-same-origin is needed for resizing and allow-top-navigation is + # needed for links with target="_parent" + ans = sandboxed_html(html, css, 'allow-same-origin allow-top-navigation-by-user-activation') ans.addEventListener('load', def(ev): setup_iframe(ev.target);) ans.style.height = '50vh' ans.dataset.last_window_width = '0'