Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.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 将JS确认(…)框替换为自定义HTML框_Javascript_Html - Fatal编程技术网

Javascript 将JS确认(…)框替换为自定义HTML框

Javascript 将JS确认(…)框替换为自定义HTML框,javascript,html,Javascript,Html,我有一个HTML按钮,点击后会转到页面,按下JS确认按钮: <button onclick="return confirm("Are you sure?"); window.location="some_page.php" type="button" class="btn">Some text </button> 您可以重新定义确认: confirm = function(text,yes,no) { //

我有一个HTML按钮,点击后会转到页面,按下JS确认按钮:

<button onclick="return confirm("Are you sure?"); 
                 window.location="some_page.php" 
        type="button" class="btn">Some text
</button>

您可以重新定义
确认

confirm = function(text,yes,no) {
    // show the modal window
    // set "yes" button to call yes()
    // set "no" button to call no()
}

或者我所做的,就是定义一个自定义函数并使用它。我使用了
Confirm
,因为JS是区分大小写的,但是你可以使用任何东西。

那么
窗口呢。showModalDialog

我使用jQueryUI对话框来代替标准的
Confirm
选项

您可以在模式中指定自己的按钮,这样就可以用“是”和“否”按钮显示“确定吗?”

confirm = function(text,yes,no) {
    // show the modal window
    // set "yes" button to call yes()
    // set "no" button to call no()
}