【问题标题】:SweetAlert box not openSweetAlert 盒子未打开
【发布时间】:2015-08-08 18:15:28
【问题描述】:

我已下载文件 .css 和 .js 并添加到我的目录中。 这样,我在我的页面中只看到一个简单的按钮“标题”。

<!-- BEGIN: MAIN VIEWER PAGE -->

<if="$mmhclass->templ->templ_globals['new_file_rating'] == true">
    <# NEW_RATING_HTML #><hr />
</endif>

<div class="text_align_center">
    <if="$mmhclass->funcs->is_null($mmhclass->input->get_vars['is_random']) == false">
        <a href="index.php?do_random=1" class="button1">New Random Image</a>
        <br /><br />
    </endif>
    <script src="sweetalert.min.js"></script> <link rel="stylesheet" type="text/css" href="sweetalert.css">
    <button type="button" id="button1" onclick='sweetAlert("Oops...", "Something went wrong!" , "error")'>Title</button>

这样我什么也看不见:

<script src="sweetalert.min.js"></script> <link rel="stylesheet" type="text/css" href="sweetalert.css">
swal({   title: "Error!",   text: "Here's my error message!",   type: "error",   confirmButtonText: "Cool" });

我正在编辑一个 .tpl 页面。我哪里错了?

【问题讨论】:

    标签: java css alert box


    【解决方案1】:

    请检查您是否已下载所有文件。

    如果已下载,请尝试将其放在文件夹中,如有必要,请在主页中将 src 路径更改为 eg:(sweetalert.min.js,sweetalert.cs)

    检查浏览器兼容性。

    之后遇到同样的问题,请告知。

    注册..

    【讨论】:

    • 我在不同的文件夹中添加了文件,现在可以使用了。 :D 但是当我按下一个按钮时警报就会开始。自动启动?
    【解决方案2】:

    用于在加载网页后自动调用警报框

    第一次清除button1的onclick()函数并将相同的函数复制到body onload事件中,像这样。

    <body onload='sweetAlert("Oops...", "Something went wrong!" , "error")'>
    

    【讨论】:

    • 谢谢。我现在正在使用它: 但是链接没有打开点击确定但连同警告框。
    • var redirectWindow = window.open('page.com', '_blank');重定向窗口。位置;试试看
    • 以这种方式工作:function(){ window.location.href = 'login.html'; });但是在新窗口中打开呢?如果我添加 '_blank' 不起作用。也许我语法错误。
    • 终于这样工作了:function(){ window.open('login.html'); });谢谢!
    猜你喜欢
    • 2022-07-21
    • 2020-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多