That also does not work (in draft mode), but this is probably because it does not have an href (and it probably uses the same code path as a normal click), so a broken GMail implementation that breaks it.
☆*PhistucK* On Tue, May 9, 2023 at 3:24 PM David Bokan <bo...@google.com> wrote: > Text fragments work just fine from `window.open` but have restrictions > about being isolated from other pages. I suspect gmail isn't adding > `noopener` in window.open so that the opened page remains reachable from > gmail. > > If that's the case, your link should work if you ctrl/cmd-click the link > or right-click>"open in new tab". > > On Monday, May 8, 2023 at 7:32:58 AM UTC-4 PhistucK wrote: > >> Looks like the issue is that opening a URL with a scroll-to-fragment via >> window.open(...) does not scroll/highlight. GMail uses window.open(...) >> in draft mode. >> >> Here is a small test case (copy it and paste it in the address bar and >> click on both of the links) - >> data:text/html,<a onclick="event.preventDefault(); >> window.open(event.target.href);" target=_blank href=' >> https://www.councilofnonprofits.org/running-nonprofit/governance-leadership/board-roles-and-responsibilities%23:~:text=Just%2520as%2520for%2520any%2520corporation%252C%2520the%2520board%2520of%2520directors%2520of%2520a%2520nonprofit%2520has%2520three%2520primary%2520legal%2520duties%2520known%2520as%2520the%2520%2522duty%2520of%2520care%252C%2522%2520%2522duty%2520of%2520loyalty%252C%2522%2520and%2520%2522duty%2520of%2520obedience%252E%2522'>window.open</a> >> <a target=_blank href=' >> https://www.councilofnonprofits.org/running-nonprofit/governance-leadership/board-roles-and-responsibilities%23:~:text=Just%2520as%2520for%2520any%2520corporation%252C%2520the%2520board%2520of%2520directors%2520of%2520a%2520nonprofit%2520has%2520three%2520primary%2520legal%2520duties%2520known%2520as%2520the%2520%2522duty%2520of%2520care%252C%2522%2520%2522duty%2520of%2520loyalty%252C%2522%2520and%2520%2522duty%2520of%2520obedience%252E%2522'>normal >> href</a> >> >> >> There is also some weird handling of the fragment. If you unescape more >> than one of the commas (%2C), it stops highlighting - >> data:text/html,<a target=_blank href=' >> https://www.councilofnonprofits.org/running-nonprofit/governance-leadership/board-roles-and-responsibilities%23:~:text=Just%2520as%2520for%2520any%2520corporation,%2520the%2520board%2520of%2520directors%2520of%2520a%2520nonprofit%2520has%2520three%2520primary%2520legal%2520duties%2520known%2520as%2520the%2520%2522duty%2520of%2520care%252C%2522%2520%2522duty%2520of%2520loyalty%252C%2522%2520and%2520%2522duty%2520of%2520obedience%252E%2522'>normal >> href with one unescaped comma</a> <a target=_blank href=' >> https://www.councilofnonprofits.org/running-nonprofit/governance-leadership/board-roles-and-responsibilities%23:~:text=Just%2520as%2520for%2520any%2520corporation,%2520the%2520board%2520of%2520directors%2520of%2520a%2520nonprofit%2520has%2520three%2520primary%2520legal%2520duties%2520known%2520as%2520the%2520%2522duty%2520of%2520care,%2522%2520%2522duty%2520of%2520loyalty%252C%2522%2520and%2520%2522duty%2520of%2520obedience%252E%2522'>normal >> href with two unescaped commas</a> >> >> Note that the URL you mentioned does not really have an accurate >> scroll-to-fragment, it uses %22 for all quotes, but the page uses special >> types of quotes (not sure why it works, but maybe there is >> some pre-processing for easier URL creation). >> >> >> You can report this at crbug.com. Be sure to search for an existing >> issue first, though. >> >> >> >> ☆*PhistucK* >> >> >> On Wed, May 3, 2023 at 1:02 AM Michael Bradley <mjmbr...@gmail.com> >> wrote: >> >>> When drafting a gmail with a link containing a *ScrollToTextFragment*, >>> Duties >>> of Loyalty, Care and Obedience >>> <https://www.councilofnonprofits.org/running-nonprofit/governance-leadership/board-roles-and-responsibilities#:~:text=Just%20as%20for%20any%20corporation%2C%20the%20board%20of%20directors%20of%20a%20nonprofit%20has%20three%20primary%20legal%20duties%20known%20as%20the%20%22duty%20of%20care%2C%22%20%22duty%20of%20loyalty%2C%22%20and%20%22duty%20of%20obedience%2E%22>, >>> clicking on the link (in Draft) shows the dialog, "Go to link: https >>> ... | Change | Remove", but following the link to test my intention to >>> scroll merely loads the target webpage. >>> >>> However, sending the draft to a Yahoo email renders the highlighted text >>> on the target webpage. This is the desired result, but it would be more >>> convenient to verify the intended behavior when testing the link in the >>> draft. >>> >>> Windows 10 Home 22H2 1/14/2021 Build: 19045.2846 >>> Chrome Version 112.0.5615.138 (Official Build) (64-bit) >>> GMail: 05-02-2023, No Add-ons, Advanced: all disabled. >>> >>> I understand the desire to disable this behavior, but I appreciate what >>> this feature can do, as demonstrated in this link. >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "blink-dev" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to blink-dev+...@chromium.org. >>> To view this discussion on the web visit >>> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/2650c78e-e0f4-4d5d-9918-62a6ece72c1cn%40chromium.org >>> <https://groups.google.com/a/chromium.org/d/msgid/blink-dev/2650c78e-e0f4-4d5d-9918-62a6ece72c1cn%40chromium.org?utm_medium=email&utm_source=footer> >>> . >>> >> -- You received this message because you are subscribed to the Google Groups "blink-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscr...@chromium.org. To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CABc02_JoLxApR4i%3Dtc5K7zv0EWZ5grfeBx29KvsLaZQ3z_CdZg%40mail.gmail.com.