jquery and hashtags in url

Posted on 2011-03-19
Medium Priority
Last Modified: 2012-05-11
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...


<!-- 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

Question by:Witheet
  • 4
  • 2

Expert Comment

ID: 35173018
Your question isn't clear.
Please specific what exactly you want.

Author Comment

ID: 35173274
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...



Expert Comment

ID: 35176006
that you do, by page.ready event, check if the hastag is the one you are looking for and then run the function
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 35176020
you can check the hash tag using
on document.ready event if hash tag matches fire event handler you want to.

Accepted Solution

Maverick_Cool earned 1000 total points
ID: 35204255
if the solution has helped you, please award the points.

Author Closing Comment

ID: 35999969
Very little information... No starting point

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question