Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    External anchor tags not working because of PHP based website?

    Hi all, totally new to this forum but I can't seem to get help from any of my friends on Facebook or other sites that generally might be able to help.

    Here's my issue, and it should seem simple, but for some reason I can't make sense of it.

    First a thing to know: 1) I'm decent with HTML and have rudimentary CSS skills, but have no clue how to code in other languages, like PHP or JavaScript.

    With that in mind, where I work I was given control over the website as our IT guys basically gave up on contracting with the guy who initially coded the site. I believe the entire site is coded with PHP, and I don't have access to the server that runs those codes.

    Anyway - Maybe that doesn't matter.

    The problem:

    I'm trying to link from one page to another page using an anchor tag to a specific section of the other page.

    For some reason, when I go to click the link to send me off to the other page, the hash and reference to that specific section simply shows up in my URL bar in my browser and the page doesn't move.

    Here's the example:

    My link on Page 1:
    Code:
    <a href="www.website.com/learnmore.php#learnmore">Click here to go learn more</a>
    The anchor on the Learn More Page 2 looks like this:
    Code:
    <a name="learnmore" id="learnmore">Learn More</a>
    When I click the link on Page 1, I am not taken to that anchor. Instead, Page 1's URL simply changes to add the #learnmore hash at the end, like this:

    www.website.com/page1.php#learnmore

    Why for the love of all that's holy does this happen? Do I need to add some type of javascript or other code to make this function properly?

  • #2
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I should add: I use Chrome. And when I inspect the element, I can click the link just fine and it sends me right to where I want the anchor to be.

    When I'm not in inspection mode, however, and I click the link, I don't get sent to the page and the URL of my current page simply adds the hash to the end of the existing URL.

  • #3
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I found a way to do it, but I'm not sure it's right or clean. Any input on that front would be appreciated, but for now this is resolved. I also realize that this solution came about due to a JavaScript fix, so this no longer may be appropriate for this forum, I apologize for that if it's the case.

    Here's what I did on Page 1 to refer to Page 2 where the anchor is:

    Code:
    <a href="#" onclick="window.location.href='http://www.website.com/learnmore.php#learnmore'";>Click here to learn more</a>
    It works in Safari, IE and Chrome at this time.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •