子窗口关闭后刷新父页面

时间:2014-08-04 13:02:50

标签: javascript jquery refresh popupwindow

目前我有一个弹出窗体显示数据列表,我希望在用户关闭弹出窗体后刷新父页面。我看了几个stackoverflow示例,主要是要求我使用 window.onunload = refreshParent; function refreshParent() { window.opener.location.reload(); }

但我尝试在我的文件中使用这些代码并且它没有用。任何人都有任何其他方法,或者任何人都可以指导我将哪部分输入我的代码。

HTML

<div id="login_form">
<table border=1>
<tr>
<th>Stages</th>
<th>Payment Percentage</th>
<th>Pay</th>
</tr>

<tr>
<td id="milestone_1"> 
</td>
<td id="percentage_1">
</td>
</tr>

<tr>
<td id="milestone_2">
</td>
<td id="percentage_2">
</td>
</tr>

<tr>
<td id="milestone_3">
</td>
<td id="percentage_3">
</td>
</tr>

</table>
<div class="err" id="add_success"></div>
<input type="button" id="cancel_hide" value="Close" />
</div>

JS

$(document).ready(function(){
$(".login_a").click(function(){
    $("#shadow").fadeIn("normal");
    var test = $(this).attr('data-id');
    var topost = 'getMilestoneDetail.php='+test;
    var returnResults = $.getJSON('getMilestoneDetail.php?id='+test,function(data)
    {
        var m1 = (data.mileStone1);
        var m2 = (data.mileStone2);
        var m3 = (data.mileStone3);

        if(m1 != ''){
        $("#milestone_1").html(data.mileStone1);
        $("#percentage_1").html(data.percentage1);
        } 
        if(m2 != ''){
        $("#milestone_2").html(data.mileStone2);
        $("#percentage_2").html(data.percentage2);
        } 
        if(m3 != ''){
        $("#milestone_3").html(data.mileStone3);    
        $("#percentage_3").html(data.percentage3);
        } 
    });
     $("#login_form").fadeIn("normal");
     $("#user_name").focus();
});
$("#cancel_hide").click(function(){
    $("#login_form").fadeOut("normal");
    $("#shadow").fadeOut();
});
});

1 个答案:

答案 0 :(得分:1)

如果您只想在用户点击关闭按钮时重新加载页面,那么您可以执行以下操作:

$("#cancel_hide").click(function(){
    $("#login_form").fadeOut("normal");
    $("#shadow").fadeOut();
    location.reload(true); //true, so it will not reload the page from browser cache
});

注意:我认为#cancel_hide是用于关闭弹出窗口的按钮..

相关问题