Solved

jquery and hashtags in url

Posted on 2011-03-19
6
1,329 Views
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...

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

0
Comment
Question by:Witheet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 7

Expert Comment

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

Author Comment

by:Witheet
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...

WKR
RV

0
 
LVL 7

Expert Comment

by:Maverick_Cool
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
0
Industry Leaders: 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!

 
LVL 7

Expert Comment

by:Maverick_Cool
ID: 35176020
you can check the hash tag using
window.location.hash
on document.ready event if hash tag matches fire event handler you want to.
0
 
LVL 7

Accepted Solution

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

Author Closing Comment

by:Witheet
ID: 35999969
Very little information... No starting point
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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

615 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