Solved

jquery and hashtags in url

Posted on 2011-03-19
6
1,309 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to use embargo Date/time in php 29 39
Where is java script information saved? 2 53
simple javascript form validation 2 20
Checkout Page Input Field not aligned 1 23
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

803 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