如何编写后退按钮的代码? [英] How to write the code for the back button?

查看:108
本文介绍了如何编写后退按钮的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有一个php代码,我想创建一个后" href,让我回到以前的状态.这是我所拥有的:

I have a php code here and I would like to create a "back" href to get me back to where I was before. Here's what I have:

<input type="submit" <a href="#" onclick="history.back();">"Back"</a>

     <html>
     <head></head>
     <body>

     <?php
     // get form selection
     $day = $_GET['day'];
     // check value and select appropriate item
      if ($day == 1) {
      $special = 'Chicken in oyster sauce';
         }
      elseif ($day == 2) {
      $special = 'French onion soup';
       }
      elseif ($day == 3) {
       $special = 'Pork chops with mashed potatoes and green salad';
        }
      else {
      $special = 'Fish and chips';
      }
      ?>

      <h2>Today's special is:</h2>
       <?php echo $special; ?>
       <input type="submit" <a href="#" onclick="history.back();">"Back"</a>
       </body>
       </html> 

推荐答案

<button onclick="history.go(-1);">Back </button>

这篇关于如何编写后退按钮的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆