美文网首页
js 实现简单弹出'确认'、'取消' 提示

js 实现简单弹出'确认'、'取消' 提示

作者: 茉茉杨 | 来源:发表于2019-11-20 14:43 被阅读0次

    一种:

    <a href="javascript:if(confirm('确实要删除该内容吗?')){location='http://www.google.com'}">弹出窗口</a>

    讲解:分解成三部分来看:

    <a href="javascript: // ">表示点击超链接后执行相应的javascript代码。

    confirm() 表示一个要求确认的对话框,用户点击确定返回true,取消则返回false。

    if(confirm())则表示,如果用户选择了确定,则执行if代码,否则什么也不做。

    二种:

    <button onclick="logout()">退出</button>

    function logout(){

        if(window.confirm('你确定要取消交易吗?')){

              //alert("确定");

               return true;

         }else{

                //alert("取消");

                return false;

         }

      }

    相关文章

      网友评论

          本文标题:js 实现简单弹出'确认'、'取消' 提示

          本文链接:https://www.haomeiwen.com/subject/xhyoictx.html