Solved

jquery and hashtags in url

Posted on 2011-03-19
6
1,296 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now