During the past week or so, I have noticed that a number of referrals from Google have been landing on my site with a URL fragment called #targetText
An example of one such referral:
php-get-last-day-of-month/#targetText=In the example above, we,parameter in our date function.
The referral above led to a tutorial about how to get the last day of a month using PHP. In another case, targetText existed as both a URL fragment and a URL parameter:
no-access-control-allow-origin/#targetText=Failed to load https://,is therefore not allowed access.&targetText=Because it is a cross,us permission to do so.
When I first spotted the URL above, I noticed that the text referenced in the URL fragment and the URL parameter are completely different from one another.
I also noticed that the fragments do not contain an exact match to the text on the page. i.e. “Because it is a cross,us permission to do so.” is not an exact match with the text on my article about “No Access-Control-Allow-Origin header is present.”
In Chrome version 74.0.3706.0, Google introduced an experimental flag called enable-text-fragment-anchor. This new feature allows users to link to a specific piece of text on a web page. The summary reads as follows:
Enable Text Fragment Anchor: Enables scrolling to text specified in URL’s fragment.
As well as introducing this new feature, it also seems as though Google have been experimenting by adding this URL fragment to the OneBox section of their search engine. i.e. If a user searches for a specific term, Google will attempt to bring the user directly to that piece of text. As well as scrolling the user down, Chrome will also highlight the text in yellow.
It will be interesting to see if Google expand’s this feature to the rest of their results and if other browsers will follow suit.