WICG / scroll-to-text-fragment

Proposal to allow specifying a text snippet in a URL fragment
Other
589 stars 42 forks source link

Nothing happened when click URL#:~:text=⚓Bug🐞 #140

Closed dnknn closed 4 years ago

dnknn commented 4 years ago

https://developers.google.com/web/updates/2020/02/nic80?hl=tr#more#:~:text=You%20can%20now,For%20example Starting from Chrome⁸¹ᐩ, URL#custom:~:text=⚓ is a useful new feature,

🔖Bookmarklet
javascript:if(target=prompt("⚓", location.href+'#:~:text=' +window.getSelection() +",")) {window.open(target);}

But after I tested it on the Chrome⁸⁴/⁸⁵/⁸⁶ version, I found a problem/Bug with it.

The following are some test example demo:

https://note.youdao.com/share/?token=4ED12C0EAAFC4C73A75CDF4F1FFF6A56&gid=115094259   The link to this page opens in a new tab👆

https://en.wikipedia.org/wiki/Rickrolling#:%7E:text=New%20York

https://github.com/WICG/scroll-to-text-fragment#:~:text=unexpected,compatible https://github.com/WICG/scroll-to-text-fragment#Bug🐞:~:text=related,indicator

https://blog.chromium.org/#:~:text=physically,foldables https://blog.chromium.org/#not-working-when-clicking:~:text=physically,foldables

https://blog.chromium.org/#:~:text=common%20coding%20issues%20to%20improve%20their%20apps%20on%20larger



But if the URL is not opened by Left-clicking, (E.g: by mouse-Middle / holding Ctrl ✚click to Open in the background tab .etc) it will can working perfectly:   👁see gif 👇

valid ⚠⚡🗣 valid by not Left-clicking 👆


 

dnknn commented 4 years ago

https://bugs.chromium.org/p/chromium/issues/detail?id=1122998

bokand commented 4 years ago

It looks like this is related to the fact that the window/tab is opened while your page still have a reference to it. For security reasons this causes text fragments to be blocked.

But the fix is simple: add rel=noopener to your links.

dnknn commented 4 years ago

But the fix is simple: add rel=noopener to your links.

https://github.com/WICG/scroll-to-text-fragment#:~:text=way.-,Additionally,navigation.,-Visual

I don't know how to use rel=noopener , It only applies to authors of website source code, right❓ I read #Security Considerations, but I don't understand rel=noopener ,because I am not a developer.

Well, since it was intentionally restricted like this, it's okay, I thought it was a bug Thank you for the reply!

bokand commented 4 years ago

Thanks for filing anyway - I agree the explainer's too low-level on this point - I'll consider how to make it more understandable.

dnknn commented 4 years ago

@bokand
I want to ask you, I don't know how to use rel=noopener , It only applies to 👤authors of 🌐website source code, right❓

Unfortunately, the #:~:text= command cannot be used directly on the left-clicking, practicality &universal will be reduced.

bokand commented 4 years ago

That's correct.

I understand now that your issue is that you don't control the website source.

It is a trade-off but without rel=noopener the two windows aren't fully independent which means the first page might be able to use the text-fragment to learn something about the second page which it shouldn't be able to do.

Unfortunately I think the way to fix this would be to request the web author update their code. Adding rel=noopener is good practice for other reasons too.

dnknn commented 4 years ago

Thank you very much for your reply, I have no doubts now, I also fully understand what you mean, there is still this communication behavior between the two windows (or called 🔌API), Thank you again, there is no problem with #:~:text= ,because just an ordinary user ^_^