0

I want to go from homepage of cece.indiana.edu/index.html to cece.indiana.edu/request.html#speaker. Even though I have the id="speaker", my request is not redirected to the specific id "speaker". I can only get this to work when I am on the request page already. Why can't I get this simple thing to work? Also, I've searched and found answers but none have fixed the problem.

Relevant code/snippets:

<h2 id="speaker" name="speaker">Request a Speaker</h2>

URL: cece.indiana.edu/request.html#speaker

If I am on cece.indiana.edu/index.html: I will go to

  1. Scroll onto Navigation bar
  2. Scroll under "get involved"
  3. Click on "request a speaker"
  4. Be redirected to the bottom of the request.html page. - this is not what I want to happen!

What I want it to do, but it is not happening: If I am on cece.indiana.edu/index.html (or any page)

  1. Scroll onto Navigation Bar
  2. Scroll under "get involved"
  3. Click on "request a speaker"
  4. Be redirected to the H2 with the id "speaker".

This not working correctly in Chrome or Firefox, but it has worked in Safari when I've tried it. I want it to work on all browsers.

j08691
  • 204,283
  • 31
  • 260
  • 272
Curb
  • 57
  • 2
  • 7
  • Possible duplicate of [HTML Anchors with 'name' or 'id'?](http://stackoverflow.com/questions/484719/html-anchors-with-name-or-id) – Evan Trimboli May 23 '16 at 22:14
  • 1
    not even close to a duplicate imo – albert May 23 '16 at 22:16
  • this is very confusing. i have no idea what the problem is....your "What I want to do" looks like it is already in place.... – albert May 23 '16 at 22:17
  • I went to http://cece.indiana.edu/request.html#speaker and it loads at the correct anchor as it should for me. – AndrewL64 May 23 '16 at 22:31
  • What browser/OS? Out of about 30 loads I had two jump further down the page. Usually this means some sizing is being dynamically processed. I see some script errors, including one related to set dimensions on a thing, but I cannot reproduce it the Chrome inspector open. – aardrian May 23 '16 at 23:03
  • I just tried it and it works fine for me. – haltersweb May 23 '16 at 23:06
  • My problem is with Chrome and Firefox. For some reason, it works fine in Safari. Go to the hompage and then go to the nav bar, get involved, and click on Request a Speaker. It takes me to the bottom of the page, if I'm coming from any page other than the get involved page. – Curb May 24 '16 at 20:58
  • Are you using Angular? – Mark May 25 '16 at 00:52
  • No, I'm not mark. Just basic HTML, CSS, and JS. This is an HTML issue, I presume. – Curb May 25 '16 at 01:07
  • Hi someone told me that this is an issue with javascript and the site's custom scrolling. – Curb May 26 '16 at 23:04

1 Answers1

0

It's the JavaScript on your page. If all JS is disabled it works fine. There is JavaScript code messing with the page load and specifically with scrolling and animation, so it's not surprising that it's interfering. Your JS even has specific references to URLs that do or do not have #anchors in them.

In this case it seems you are being sent to the bottom of the page because the "smooth scrolling" code in your JS isn't taking into account that the page may already be scrolled part way. Some browsers will "remember" where you had scrolled to last time you loaded a page, so particularly if you use the back button and then click the navigation item again, you'll end up scrolled too far.

If you have the ability to change the JS, you can fix this by making sure the smooth scrolling code ends by checking to make sure it's actually in the right spot, maybe after a small delay.

  • Thanks for your in-depth answer. It's from a free theme. Is there anything specific I should look for in the JS files? – Curb May 27 '16 at 22:06