doulingzou1712 2013-03-07 21:34 采纳率: 0%
浏览 82
已采纳

在PHP / Javascript中调用浏览器后退按钮

I have a form which sends the user to a different form incase they don't complete it to go back to the form and complete anything that was missed. Now unless the user presses the browser back button the page is loaded fresh which mean any data gets lost.

Pretty much when they come back to the previous page, anything they already filled in should stay intact.

I have the following two pages:

Page 1:

<?PHP

echo "<a href='page2.php'>NEXT</a>";
echo "<input type=text size=25 name=txt />";
?>

Page 2:

<?php
$refer = $_SERVER['HTTP_REFERER'];
$lastlink = "<a href='$refer'>BACK</a>";

echo $lastlink;
?>

On page two if i click BACK to come back to page 1, anything entered in page 1 will be lost which I do not want. How do I work around it without using Javascript? with Javascript? I know in javascript I can use

<a href="javascript:history.go(-1);">BACK</a>

But is there another way?

  • 写回答

3条回答 默认 最新

  • douzhi1919 2013-03-07 21:36
    关注

    Take a look at html5 history api. History api + ajax is great combination

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?