简体   繁体   English

javascript / php后退按钮

[英]javascript/php back button

I have this piece of code: 我有这段代码:

            if (file_exists($filedir)) {
            ?>
                <script>alert('File "<?php echo "$filename"; ?>" already exists.');</script>
            <?php
            echo <<<HERE
            <input action="action" type="button" value="Back" onclick="history.go(-1);" />
HERE;

So, how can i embed heredoc part of script into javascript alert box, in order to have alert message and back button in the same alert box ? 因此,如何将脚本的heredoc部分嵌入到JavaScript警报框中,以便在同一警报框中包含警报消息和后退按钮? I've tried to add: 我尝试添加:

header("Location:    ");

after the alert box, but that sends me back one page without the javascript alert message. 警报框之后,但这使我返回一页而没有javascript警报消息。

Thx for the help 谢谢你的帮助

Maybe javascript confirm() is what you want? 也许JavaScript Confirm()是您想要的吗?

http://www.w3schools.com/jsref/met_win_confirm.asp http://www.w3schools.com/jsref/met_win_confirm.asp

you can do something like this: 您可以执行以下操作:

echo <<<HERE
<script>alert('File "$filename" already exists.<input action="action" type="button" value="Back" onclick="history.go(-1);" />')</script>
HERE;

but that wont show button, for that you have to use confirm or prompt javascript methods 但这不会显示按钮,为此您必须使用确认或提示javascript方法

得到它了:

alert('Go back'); window.location.href = "home.php";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM