后退按钮的代码怎么写?
我这里有一个 php 代码,我想创建一个“后退”href 来让我回到之前的位置。这是我所拥有的:
<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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果你想这样做(我认为你现在正在尝试),那么用
这个
替换这一行如果你不想依赖JavaScript,那么你可以获取
HTTP_REFERER
变量,然后提供它在这样的链接中:If you want to do it (what I think you are trying right now) then replace this line
with this
If you don't want to rely on JavaScript then you could get the
HTTP_REFERER
variable an then provide it in a link like this:这个(by Eiko)很完美,用css做了一个
按钮...
例如,您可以在
中使用此 css 类作为`
this one (by Eiko) is perfect, use css to make a button of
<a>
...eg you can use this css class in
<a>
as `您需要告诉浏览器您正在使用 javascript:
此外,您的输入元素在代码中似乎不合适。
You need to tell the browser you are using javascript:
Also, your input element seems out of place in your code.
由于未封闭的
input
元素,HTML 无效。就足够了
Is invalid HTML due to the unclosed
input
element.is enough
在我的应用程序中,上面的 javascript 函数不起作用,因为我在一个页面中有很多 procrosses。所以下面的代码对我有用,希望它对你们有帮助。
In my application,above javascript function didnt work,because i had many procrosses inside one page.so following code worked for me hope it helps you guys.
基本上我的代码将数据发送到下一页,如下所示:
Basically my code sends data to the next page like so: