Closed rcrath closed 3 years ago
Hi @rcrath , I believe the issue is that you're using the id instead of the name for your anchor links. For example, this link works for me.
Actually, that link doesn't appear to be working so well — it opens a consistent internal location in the page, but I believe it's the location of the anchor before Scalar processes the page contents, which may be different from where the anchor ends up. (You can verify by changing the layout of the destination page to Blank Slate, which removes most of the processing, and then trying the link). I don't know of a workaround or fix for this at the moment.
Hi @rcrath,
You can give this a try (plug it in to the "Custom Javascript" box in the Edit page of the page in question):
$(document).ready(function() {
$('body').on('pageLoadComplete', function() {
var hash = document.location.hash;
if (!hash.length) return;
hash = hash.substr(1); // remove #
var pos = $('a[name="'+hash+'"]').position();
window.scrollTo(pos);
});
});
Thanks. Will try. Looks from the JavaScript that a need to add "name" field to H1 or replace id with name. I used id because I got a warning for name being obsolete when I linted it, but I'm fine with whatever gets the job done!
Had to create full old <a nname>
targets. Then it worked with the is snippet. Thanks!
OK, apropos, #154 it seems there is some kind of url rewrite that strips out the IDs for external links. So my page has a TOC with internal links that works fine if I click within the page, but when I go to the URL as an external link with a fragment ID e.g.
http://example.com/scalar/testimony#smith-tues-Spet-23-2020
, then it does not go to the ID.So here is the page:
http://udigix.net/scalar/ethnic-studies-anniversary-/testimony
find the "Howes" link and click it. It works. Now take the url of the fragment link: http://udigix.net/scalar/ethnic-studies-anniversary-/testimony#howes-tue-sep-15-2020-4-39-am or just click on the quotation on the community page and the fragment link will fail to go to the location.