Avatar of befidled
befidled

asked on 

Help with Anchor Hash tag

I have a page where I am using a number of Anchor hash tags to dynamically change the content on the page: http://waldronsfarm.com/index.php/products/

the hash tags are the secondary navigation that includes Groundcovers, Cacti, Trees, etc.

The issue I am having is that I am using named anchors to modify the filtering of my table (click on subcategories, i.e. http://waldronsfarm.com/index.php/products/#Groundcovers), but the page is repositioning itself to align the named anchor at the top of the page. How can I turn this off so that it doesn't do this?

thanks
HTMLJavaScript

Avatar of undefined
Last Comment
Designbyonyx
Avatar of Jason C. Levine
Jason C. Levine
Flag of United States of America image

Don't use the # character.  The browsers will always move to the position.  
or don't have name="Groundcovers" or id="Groundcovers"
ASKER CERTIFIED SOLUTION
Avatar of Designbyonyx
Designbyonyx
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Designbyonyx
Designbyonyx
Flag of United States of America image

Should have been a little more descript.

You will need to view the "console" to view the output of this code.  Chrome and Opera and consoles built into the browser.  Firefox requires the Firebug addon for the console.

You can set up your hashes like this:

#filter-SomeHash
#sort-SomeHash
#SomeHash

You can also add other "actions" by modifying the regular expression... separating different "actions" with a pipe:

filter|sort|action1|action2

For each "action" you will need to add a "case" in the "switch" statement (see code).

Hope that helps.
Avatar of befidled
befidled

ASKER

Thanks that sounds like it is worth a try. I may just try changing Name to ID first and if that doesn't work I'll try the plugin.
Avatar of Designbyonyx
Designbyonyx
Flag of United States of America image

Changing name to id wont work... I can save you the trouble.  Anything with an ID can be treated as a "named anchor" (even if the element is not an anchor tag).  For example, a url like this:

http://www.domain.com/#footer

would cause the browser to scroll all the way down to the footer element (assuming the footer has an ID of "footer")

<div id="footer">...</div>
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo