Link to home
Start Free TrialLog in
Avatar of Witheet
WitheetFlag for Netherlands

asked on

jquery and hashtags in url

Hello all,

I have a question about adding hashtags to end of url to execute a jquery function...

I use the following code to slide up div when clicked on a link in a single page site...

I want to try and use back button functionallity and more importantly bookmarking on this page so that when one goes to: myurl.com#hashtag the jquery statement now only triggered by clicking the set link is also executed... How would I have to (re)write the following code to realise this? I have commented out the event.preventDefault(); to get the hashtag added to the url... But whats next?

Tyvm in advance for any tips and suggestions in the right direction...

WKR RV


<!-- The link in html page -->
<a href="#hashtag" class="hashtag" title="hashtag test">Slide up footer </a>

<!-- Button hashtag -->
$("a.hashtag").click(function(event) {
// event.preventDefault();
$("#fullWidthFooter").animate({'height': '50'}, 1400, 'easeOutBounce');
});

Open in new window

Avatar of Maverick_Cool
Maverick_Cool
Flag of India image

Your question isn't clear.
Please specific what exactly you want.
Avatar of Witheet

ASKER

Hello and ty for your reply...

What would I have to change in given jquery statement to execute the jquery function not only when supplied link is clicked but if one was to visit the page using example url: myurl.com#hashtag... The current statement slides in the footer div only when you would click the sample link while visiting the page... I would like to have the footer div also slide out if you would enter the url: myurl.com#hashtag directly in your addressbar...

WKR
RV

that you do, by page.ready event, check if the hastag is the one you are looking for and then run the function
you can check the hash tag using
window.location.hash
on document.ready event if hash tag matches fire event handler you want to.
ASKER CERTIFIED SOLUTION
Avatar of Maverick_Cool
Maverick_Cool
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Witheet

ASKER

Very little information... No starting point