codeigniter的控制器到特定div中的主控制器

问题描述 投票:1回答:1
<li><a href="maine/home#services">SERVICES</a></li>
<li><a href="maine/home#about">ABOUT</a></li>
<li><a href="maine/home#contact">CONTACT</a></li>

我正在使用CodeIgniter,并且此代码位于不同的控制器中。假设http://localhost/defctrl/function1

当你点击列表时,我想返回到我的主页"maine/home"特定div,但上面的代码不起作用。没有../maine/home#services.

我怎么解决这个问题?

php html5 codeigniter codeigniter-3
1个回答
1
投票

如果它在同一页面上你可以使用

<li><a href="#services"

如果是另一页

<li><a href="<?php echo base_url() ?>{route or controller name}#services"

确保加载URL帮助程序并使用index.php加载站点

© www.soinside.com 2019 - 2024. All rights reserved.