kevin4
February 10, 2023, 5:23pm
1
I’m trying to use the Toolbox plugin to run the following Javascript:
window.open('url#:~:text=string','noopener _blank')
Where url and string are values contained in custom states.
What happens is the webpage is opened as expected, and the URL is properly formatted with “string” (shown below), but the browser does NOT scroll to the string.
EXCEPT…
When I open a new browser tab and paste the generated URL into the new browser tab, it loads the webpage AND scrolls to “string”.
https://organicgrowth.biz/link-building/you-do-not-want-backlinks-to-your-landing-pages/#:~:text=Product%20Led%20Content%20%E2%80%93%20Should%20You%20Try%20It%20for%20Your%20SaaS?
Has anyone else seen this?
Has anyone solved this?
I also tried this with the CustomJS action of the Zeroqode Toolbox, and it produces identical behavior.
are you sure the linked page has an element with the same id of the fragment?
kevin4
February 10, 2023, 6:50pm
3
The purpose of using Text Fragments is to avoid using IDs completely.
I have no control over the page in question. There may or may not be IDs.
And, I know Text Fragments work because I can paste the constructed URL into a browser tab I manually open, and the scrolling works properly.
You may want to read this
edit: my mistake, you are talking about text fragment, my link is for a different thing
kevin4
February 10, 2023, 7:38pm
5
Yes.
Document fragments and text fragments are different.
From mdn :
Text fragments are invoked only on full (non-same-page), user-initiated navigations
Have you tried to see if it works with a link element?
Maybe the execution with the toolbox is not considered as an user-initiated navigation.
kevin4
February 10, 2023, 8:07pm
7
Dude… You are a rock star!!
And I’m embarrassed that using a link element never occurred to me.
When I use a link element, I see the desired behavior.
THANK YOU!
system
Closed
April 21, 2023, 5:23pm
8
This topic was automatically closed after 70 days. New replies are no longer allowed.