获取以前的URL并用作codeigniter中的后退按钮

Den*_*nis 3 php url codeigniter

我真的很想知道我怎么能这样做,我有3个页面有相同的链接到1页,现在我想做的是有一个智能足够的按钮,以获得3页中的哪一页用于去该页面并将其用作返回上一页的链接.

如果有人知道如何做到这一点,请帮助我摆脱这种混乱.发布一些代码如何在codeigniter中做到这一点.先感谢您.

Vin*_* VT 7

通过使用简单的javascript来实现以前的按钮,

<a href="javascript:window.history.go(-1);">Previous</a>
Run Code Online (Sandbox Code Playgroud)


小智 5

加载url 帮助程序后,在隐藏字段(如“refer_from”)中设置 current_url。

<input type="hidden" name="refer_from" value="<?php echo current_url(); ?>" />
Run Code Online (Sandbox Code Playgroud)

使用输入类获取它并将其设置在锚链接上

<a href="<?php echo $this->input->post('refer_from'); ?>">Previous</a>
Run Code Online (Sandbox Code Playgroud)

注意:如果用户以某种方式直接登陆到“1”最后一页,那么使用 window.history.go(-1) 将失败并抛出 js 错误。在这种情况下,window.history 将为空。