CodeIgniter Forums
How to link with a hash in URL? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: How to link with a hash in URL? (/showthread.php?tid=70225)



How to link with a hash in URL? - lnzbuyao - 03-10-2018

I am trying to create a simple link as seen in the code below.
Code:
<li class="nav-item">
    <a class="nav-link" id="nav-item" href="<?=site_url('Home#About');?>"> About</a>
</li>
What I want to happen is when the user clicks the link, it will take them to the section of the page it's linked to.  When I click this, nothing happens.  I have tried configuring the routes.php file to allow the link to work, but nothing happened. 

Manually typing in the URL works fine.  

What kind of workaround would you recommend for this?  Thank you in advanced!


RE: How to link with a hash in URL? - jreklund - 03-10-2018

I can get it to work with both 'welcome#footer' and 'welcome/#footer' without modifying anything but base_url (config), loading url helper (controller) and modifying the view (welcome_message).
As it works with manually typing in the URL, I guess you got the id="footer" in place.

Try deleting all JavaScript in case it high-jacks the default behavior.


RE: How to link with a hash in URL? - InsiteFX - 03-10-2018

SEE: HTML Links - Create a Bookmark

HTML Links