js 改变 win alert 样式

js 改变 win alert 样式 实现弹框提示效果

<!DOCTYPE html>

<html>
<style>
  #alertdiv {
    position: absolute;
    padding: 0 20px 0 60px;
    top: 30%;
    right: 5%;
    text-align: center;
    line-height: 28px;
    font-size: 14px;
    font-family: SourceHanSansCN-Regular;
    box-shadow: 0px 3px 20px 0px rgba(26, 41, 55, 0.1);
    border-radius: 3px;
  }

  #alert-title {
    font-size: 16px;
    color: #303133;
    float: left;
    font-weight: bold;
  }

  #cancel {
    width: 12px;
    float: fight;
    position: absolute;
    top: 15px;
    right: 20px;
  }

  #right {
    width: 20px;
    float: left;
    margin-left: -30px;
    margin-top: 3px;
  }
</style>
<head>

  <meta charset="UTF-8">

  <title>HTML5学堂 - alert</title>

</head>

  <script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"></script>
  <script type="text/javascript">
    (function () {
      window.alert = function (text) {
        //解析alert内容中的换行符
        text = text.toString().replace(/\\/g, '\\').replace(/\n/g, '<br />').replace(/\r/g, '<br />');

        // 自定义DIV弹窗
        var alertdiv =
          '<div id="alertdiv">'
            +'<img id="cancel" src="./img/cancel.png" onclick="$(this).parent().remove(); "/><br />'
            +'<img id="right" src="./img/right.png" /><div id="alert-title">注册成功</div><br />'
            +'<div id="note">您的注册申请提交成功,请耐心等待工作人员联系您</div>'
            +'<br/></div></div>'
        $(document.body).append(alertdiv);
        // 显示
        $("#alertdiv").show();
      };
    })();
  </script>
<body>
  <input type="submit" name="button" id="button" value="点击" onclick='alert("")' />
</body>

</html>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值