Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 窗口。确认将取消按钮取出_Javascript_Html - Fatal编程技术网

Javascript 窗口。确认将取消按钮取出

Javascript 窗口。确认将取消按钮取出,javascript,html,Javascript,Html,如何从窗口中取出“取消”按钮。确认?? 是否有办法将其取出,然后只显示“确定”按钮?如果您不想使用“取消”按钮,您最好使用alert(): 在美丽的ascii艺术中,它看起来是这样的: +-----------------------------------+ | | |这个操作是不可能的| | | | +--------+

如何从窗口中取出“取消”按钮。确认??
是否有办法将其取出,然后只显示“确定”按钮?

如果您不想使用“取消”按钮,您最好使用
alert()

在美丽的ascii艺术中,它看起来是这样的:

+-----------------------------------+
|                                   |
|这个操作是不可能的|
|                                   |
|            +--------+             |
||好||
|            +--------+             |
+-----------------------------------+
单击OK或取消对话框时,将执行代码中的下一条语句


如果下一条语句应该是有条件的,很遗憾,您必须坚持使用
confirm()

窗口。您需要的是警报


或者简单地
警报
,就像
窗口一样。确认
可以是
确认
(除非您隐藏带有这些名称的变量。

您可以简单地使用
警报
。以下是一个示例:

HTML 这是一个可行的解决方案。由于JSFIDLE,我不得不使用iframe。在您的场景中,您可能希望删除iframe,只需更改:

page.attr('src','http://www.monkeyman.com);


window.location('http://www.monkeyman.com“);

如何在警报中设置ok?与窗口相同。确认?@user2242573,
警报(“消息”)
我的意思是,当我单击ok时,它将转到另一个窗口page@user2242573,
alert(“message”);window.location=“newURL”
如何编程“确定”按钮,使其在单击时转到另一个按钮page@user2242573单击OK(或对话框关闭按钮)后,将运行下一条语句;如果希望此操作可取消,则必须坚持使用
confirm()
尽管如此。@Ja͢ck你有没有看到警报不会阻止程序,程序会执行下一条语句?@yuanshillamaculelêLai我想
警报()
可能会被另一个实现覆盖,不确定
alert('This operation is not possible');
<button id="test"> Go To Another Page</button>
<br><br>
<iframe src='http://www.example.com' height="400px" width="100%" id="page"></iframe>
$(document).ready(function(){
    $('#test').click(function(){
        var page = $('iframe');
        alert("You'll be redirected to a new page now");
        page.attr('src', 'http://www.monkeyman.com'); // This line is executed once you hit ok on the alert.
    });
});