引导data-dismiss =“alert"——然后重定向到另一个页面

bootstrap data-dismiss="alert" -- and redirect the other page

本文关键字:重定向 然后 另一个 data-dismiss alert quot 引导      更新时间:2023-09-26

我有以下PHP和HTML与BS代码:

<?php if (isset($_GET['register']) && $_GET['register'] == 'get') {?>
    <div class="alert alert-danger success">
        <button type="button" class="close" data-dismiss="alert" onclick="return refresh('index.php')">×</button>
        <strong>The register must be done with GET!</strong>
    </div>
<?php }?>

通过$_GET superglobal将错误从register.php发送到index.php,该错误在index.php中使用上述代码"捕获"。此时,我的URL是index.php?register=get。我想要两个东西:

  1. 用class="alert"(已经完成)取消div
  2. 当报警-危险信息的小"x"被按下时,重新加载页面,使?register=get消失,URL变成简单的:index.php

直到现在我已经试过了:

  1. JS函数用"onclick" HTML属性调用

    function refresh(page){ return window.location.href(page); }

  2. <button type="button" class="close" data-dismiss="alert" id="close1">×</button>

和我使用以下jquery代码:

$("#close1").on("click", function () {
    window.location.href("http://localhost/ampera/src/supervizor/app/sef_locatie_nou.php");
});

我使用绝对和相对路径的jquery代码,没有工作。并且该代码只忽略警报-危险消息,而不根据需要重新加载页面。

尝试窗口。开放:

window.open("http://localhost/ampera/src/supervizor/app/sef_locatie_nou.php", "_self");
演示:

http://jsfiddle.net/Rj9bR/54/

try this

$("#close1").on("click", function () {
    location.assign("http://localhost/ampera/src/supervizor/app/sef_locatie_nou.php");
});