-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Anchor link with complete URL #51
Comments
Hi @Anke, did you solve this issue in any way? |
Uh, thank you for your reply, but honestly - I don't know. I might have, but might just as well have implemented another script. Sorry. |
Really hacky solution, but I wanted something simple rather than sinking any time into it. I ended up with: $('.toc').on('click', 'a', function() {
var fixedUrl = window.location.href.split('#')[0] + $(this).attr('href');
setTimeout(function() {
window.location.replace(fixedUrl);
}, 600);
}); The timer is for the url to update once the smooth scroll has finished + a lil bit of padding. Awkward, but works. @030media @Anke |
Thanks a lot, I will give it a try once I have to use a TOC again! |
Great, I'll try that. Thanks! |
Hi,
thanks for this neat script. Using a CMS I need to add the URL to the anchor name in the link, so I changed line 70 from
.attr('href', '#' + anchorName)
to
.attr('href', window.location + '#' + anchorName)
.EDIT:
The above change of code seemed to be working well at first, but now I realise that something isn't working well. Clicking on another link now, the anchor is being added to the URL - http://mydomain.com/mypage.html#toc38#toc19. Refreshing the page adds yet another anchor to the URL etc.
Did I trigger this behavior by adding window.location? Is there a solution for this?
I'd very much appreciate your help,
Anke
The text was updated successfully, but these errors were encountered: