Friday, October 30, 2026

Anchors - blog page internal markers

This morning I had a hankering to read about the last song that I ever completed, "Maeve's song". This appears in blog #19321, and it references blog #19212. But when I clicked on the link to the earlier blog, I found myself reading about Passover 2025; I asked myself what this has got to do with "Maeve's song".

It turns out that blog #1921 is one of those that is about two completely different subjects (maybe now I would write two separate blogs), and the material about Maeve starts only halfway through the blog. How could I access this part immediately? I remembered that one can add anchors to HTML pages in order to mark section headings and that these anchors are valid targets for a browser. I could see immediately that there were two problems with the code within the Blog Manager Program (BMP) as it currently stands: one trivial and one more complicated that I didn't know how to solve.

The trivial problem was that the link would be <A href="https://nbnewman.blogspot.com/2025/04/passover-begins-tonight.html#maeve" target=_blank> and there is no blog entry with that address. Obviously the anchor (#maeve) has to be extracted so that the correct blog entry can be found.

But the complicated problem was how to pass the anchor to the browser. It turns out that this is almost as trivial as extracting the anchor. Obviously the anchor has to be passed as a parameter to the TShowBlogContent.Create constructor and saved in a form variable. Instead of opening/displaying the web page by means of the command 'web.navigate (s)'where s is the name of a text file containing the blog's text, that variable s is modified in the line prior to this: the anchor is attached to the file name. So the string being passed to web.navigate would be something like 'c:\db\blog\data\blog_1921.htm#maeve'. Easy peasy. The only thing that I missed originally was the anchor tag within the target blog: it should be <a id="maeve"></a>.

Internal links
[1] 1932
[2] 1921



This day in blog history:

Blog #Date TitleTags
42130/10/2011Sir Jimmy SavileObituary, RIP
42230/10/2011Succulent SundayCooking, Slow cooker
77130/10/2014Another good ideaERP
118130/10/2018Losing an old friend, gaining a new oneComputers
143330/10/2021Binaural beats and deep sleepCPAP, MP3, The brain, Binaural beats, Sleep
154330/10/2022Adding more old blog entriesProgramming, Meta-blogging, Blog manager program
202830/10/2025Counting beats with Van der Graaf Generator (5) - After the floodVan der Graaf Generator

No comments: