[Answer]-Anchoring Across Different Pages

1👍

The question isn’t clear, but I assume you have a javascript function that takes a string and finds the correct place to send the user. In that case, you can run this on page-load with the page’s current hash:

$(function() {
    if (location.hash) {
        var question = location.hash;
        var answer = $.find('dt:contains(' + question + ')');
        $('html, body').animate({
            scrollTop: $(answer).offset().top
        }, 200);
    }
});

And your email link can look like this:

<li><a href="contact#email">Email</a></li>

Or, if you want to use the <a> content as the hash:

<li><a href="contact">Email</a></li>
...
$(function() {
    $('a').each(function(){$(this).attr('url',$(this).attr('url')+'#'+$(this).text())});
});

this will turn that link into:

<li><a href="contact#Email">Email</a></li>
👤000

0👍

Just do…

<li><a href="contact#email">Email</a></li>
<li><a href="contact#onsite">On Site</a></li>
<li><a href="contact#social">Social Media</a></li>

Then set the anchors on the page youre talking about

Like so….

//email section to link to
 <div id="email"></div>
//onsite section to link to
 <div id="onsite"></div>
👤Kylie

Leave a comment