在灯箱中使用Javascript按钮

时间:2012-10-09 06:55:41

标签: javascript lightbox2

我正在寻找一种在提交信息后让灯箱窗口关闭的方法。

现在如果这还不够;我也希望有一个灯箱刷新它的父页面。

既然你知道我有多么需要,我现在就会展示自己拥有的东西。

我的JavaScript更新查询按钮:

<script type='text/javascript'>
function close_and_refresh(){
    //Reload The Parent Page
    opener.location.reload();
    //And then Close the Entry Page
    close();
}
</script>

我指定的按钮:

<input type="submit" value="Update" onclick="close_and_refresh();" />

我认为它会奏效,但事实并非如此;如果有人知道如何实现这一点,那就太好了。

2 个答案:

答案 0 :(得分:0)

更改输入类型提交到输入类型按钮

<input type="button" value="Update" onclick="close_and_refresh();" />

答案 1 :(得分:0)

提交表单后,在litebox iframe中,您可以让iframed页面写出一些调用父文档中的函数的javascript。

一个非常基本的设置是这样的:

父pavascripts中的

<script type="text/javascript">
    function closeLitebox() {
        // close your litebox
    }
</script>
成功提交后,在iframe页面中

<script type="text/javascript">
    parent.closeLitebox();
</script>

在谷歌搜索“从iframe调用父级”之类的内容,有大量可用的样本......