Javascript 将JS确认(…)框替换为自定义HTML框
我有一个HTML按钮,点击后会转到页面,按下JS确认按钮: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) { //
<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()
}