【发布时间】:2015-07-28 12:33:53
【问题描述】:
我有以下带有 BS 代码的 PHP 和 HTML:
<?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 中使用上述代码“捕获”。此时我的网址是index.php?register=get。我想要两件事:
- 使用 class="alert" 关闭 div(已经完成)
- 当按下 alert-danger 消息的小“x”时,重新加载页面,这样 ?register=get 就消失了,URL 变成了简单的:index.php
到目前为止我已经尝试过:
-
使用“onclick” HTML 属性调用它的 JS 函数
function refresh(page){ return window.location.href(page); } <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 代码使用了绝对路径和相对路径,都没有工作。并且代码只会关闭警报危险消息,但不会根据需要重新加载页面。
【问题讨论】:
-
您使用的是哪个 jquery 版本?
-
jquery-1.11.3.min.js
标签: javascript php jquery html twitter-bootstrap