网站添加SweetAlert弹窗公告

菜鸟
2025-09-14 / 2 评论 / 39 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2025年09月14日,已超过62天没有更新,若内容或图片失效,请留言反馈。

SweetAlert 使弹出消息变得简单而漂亮。

Test

代码来了
<script src="https://cdn.bootcss.com/sweetalert/2.1.0/sweetalert.min.js"></script>

<script>
  // 页面加载后弹出提示
  swal({
    title: "本站状态:稳定运行中",
    text: "感谢您来到本站,祝您购物愉快!\n\n",
    icon: "success",
    button: "确定"
  });

  function AddFavorite(title, url) {
    try {
      window.external.addFavorite(url, title);
    } catch (e) {
      try {
        window.sidebar.addPanel(title, url, "");
      } catch (e) {
        alert("抱歉,您所使用的浏览器无法完成此操作。");
      }
    }
  }
</script>
修改图标

Test

successerrorwarninginfo
successerrorwarninginfo

单页源码

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>恭喜,站点创建成功!</title>
    <style>
        .container {
            width: 60%;
            margin: 10% auto 0;
            background-color: #f0f0f0;
            padding: 2% 5%;
            border-radius: 10px
        }

        ul {
            padding-left: 20px;
        }

            ul li {
                line-height: 2.3
            }

        a {
            color: #20a53a
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>恭喜, 站点创建成功!</h1>
        <h3>这是默认index.html,本页面由系统自动生成</h3>
        <ul>
            <li>本页面在FTP根目录下的index.html</li>
            <li>您可以修改、删除或覆盖本页面</li>
            <li>FTP相关信息,请到“面板系统后台 > FTP” 查看</li>
        </ul>
    </div>
<script src="https://cdn.bootcss.com/sweetalert/2.1.0/sweetalert.min.js"></script>

<script>
  // 页面加载后弹出提示
  swal({
    title: "本站状态:稳定运行中",
    text: "感谢您来到本站,祝您愉快!\n\n",
    icon: "success",
    button: "确定"
  });
  

  // 收藏夹添加函数
  function AddFavorite(title, url) {
    try {
      // IE 浏览器
      window.external.addFavorite(url, title);
    } catch (e) {
      try {
        // Firefox 浏览器
        window.sidebar.addPanel(title, url, "");
      } catch (e) {
        alert("抱歉,您所使用的浏览器无法完成此操作。");
      }
    }
  }
</script>

</body>
</html>
本文共 201 个字数,平均阅读时长 ≈ 1分
0

评论 (2)

密语
  1. 头像
    ikun
      Windows 10 x64 EditionWindows 10 x64 Edition / Google Chrome 132.0.6834.83Google Chrome 132.0.6834.83
    沙发 安徽省合肥市

    画图

    回复 删除 垃圾