Overlay: Fixed handling of same-page links to elsewhere on the page

Fixes #5767
Merge pull request #5773 from pjackson28/fixsamepagelinksoverlay

Overlay: Fixed handling of same-page links to elsewhere on the page