Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Anchor Tags Not Working
#1
I could use some help figuring out why my anchor tags are not working. I want to link to a specific line of text on another page on the site using the following markup:

<div class="team"><a href="staff#jacquie">Jacquie Wyant</a></div>

<a name="jacquie">Jacquie Wyant</a>

Any help would be greatly appreciated!

See attachments for details.
Reply
#2
use ids not names
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#3
<div class="team"><a href="/staff#jacquie">Jacquie Wyant</a></div>
Reply
#4
No
<a id="jacquie">Jacquie Wyant</a>
<h1 id="jacquie">Jacquie Wyant</a>
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#5
That should be fine, according to browser tests I did a while ago: 

Quote:Apparently Mozilla Firefox doesn't associate the id attribute with a location in the HTML Document for elements other than <a> but uses the name attribute instead, and Google Chrome does exactly the opposite. The most cross-browser proof solution would be to either:
1.Give your anchor divs both a name and an id to ensure max. browser compatibility, like:
<a href="#map">Go to Map</a> <!-- Link -->
----
<div id="map" name="map"></div> <!-- actual anchor -->
Demo: http://jsbin.com/feqeh/3/edit
2.Only use <a> tags with the name attribute as anchors.

In this case, if Jacquie is a location on the same page the href attribute should be #jacquie and if it's on another page called staff it should be staff#jacquie, and should work regardless whether you're using a named anchor or id'd element.

If you're using ID's and want to be absolutely sure it works you can always put this type of script at the bottom of the linked page:
Code:
<script>
  var loc = location.href;
  if (loc.match('#')) && document.getElementById(loc.split('#')[1]))
     document.getElementById(loc.split('#')[1]).scrollIntoView();
</script>
Reply
#6
on my site all the anchor work and name and id
http://gs-blog.business-website.ru/yakorya/
maybe he uses the plugin Custom menu
Reply
#7
Thanks for all the input from everyone, however I tried both id and name and neither works. It goes to the proper page but doesn't find the tagged div. Any ideas?
Reply
#8
what browser? works for me
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#9
I've viewed it in Safari, Chrome and Firefox so far. Like I said, the link goes to the staff page but it doesn't take you to the tagged div on the page. Go to www.challengeyourbody.com and on the "About Us" page, click on Kevin Needler's name. It should go to his bio on the page, but doesn't.

Thanks for looking.
Reply
#10
your link anchor has quotes around it
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#11
(2015-05-29, 04:55:27)shawn_a Wrote: your link anchor has quotes around it

Lol yeah the referring link is http://www.challengeyourbody.com/about-us/"staff#kevin”.
Should be http://www.challengeyourbody.com/staff#kevin
Reply
#12
Code:
<a href=“staff#kevin”>Kevin Needler</a>
replace it
Code:
<a href="staff#kevin">Kevin Needler</a>
Reply
#13
Well, thanks everyone. It's the small things that trip me up! LOL!
Reply




Users browsing this thread: 1 Guest(s)