Browser back button does not work for Anchor links

后端 未结 4 2495
广开言路
广开言路 2021-02-20 08:36

In the footer of my page there a few links that point to different sections on the same page using anchor tags (# appended to the URL of the page).

This works fine, just

4条回答
  •  礼貌的吻别
    2021-02-20 09:28

    History and the Back Button.

    In days of old, the back button did little more that go to the previous item in the browser's history. That's changed quite a bit since then, as it keeps its own history according to a somewhat simple set of rules. Good luck digging through standards docs to find it though.

    UI/UX and why NOT to change expected behaviors.

    Please reference w3c's 'don't brek the back-button before you go making changes to a browser's default behavior. Its like that for a reason, following mountains of debate and defining standards.

    Ultimately, this is what browsers do, and so this is what the users expect. If you begin to subvert the behavior away from user's expectations, you're likely to start pissing off your users. When buttons and links repeatedly don't behave as expected, users will often just give up and leave your site.

    Prevent Default.

    If you really must alter the default behavior, the using javascript would be the best way to do it:

    
    
    
    

提交回复
热议问题