【问题标题】:Refreshing parent page after child FORM close子FORM关闭后刷新父页面
【发布时间】:2014-08-04 13:02:50
【问题描述】:

目前我有一个显示数据列表的弹出表单,我希望在用户关闭弹出表单后刷新父页面。我看过一些 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();
});
});

【问题讨论】:

    标签: javascript jquery refresh popupwindow


    【解决方案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 是用于关闭弹出窗口的按钮..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-21
      • 1970-01-01
      • 2014-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多