dongtang3155 2014-08-22 06:57
浏览 57

在某些情况下,我的代码不刷新父页面

I am using a thick box and want to refresh parent page when thicbox is closing. I use below code but it works sometime and dont work in some situations... waht is the problem with it?

<script>
    function close2()
    {
       parent.tb_remove();
       parent.location.reload(1)
    }
</script>

<input type="submit" name="save_new_task" id="save_new_task" onclick="close2()" style="width: 100px;text-align: center;" 
  class="button button-primary button-medium" value="<?Php _e("register","creat_mysite");?>"/>
  • 写回答

2条回答 默认 最新

  • douye2111 2014-08-22 07:11
    关注

    Maybe it is because your submitting the form before the JavaScript get executed? If you want to submit your form and then perform a Javascript function you can try this:

    $(document).ready(function()
    {
        $('#save_new_task').click(function(e)
        {
            e.preventDefault();
    
            //Serialize your form
            //POST request
    
    
            //Maybe also try window.opener instead of parent
            //window.opener refers to the window that called window.open( ... ) to open the window from which it's called
            //window.parent refers to the parent of a window in a <(i)frame>
            window.opener.tb_remove();     
            window.opener.location.reload(); 
        });
    });          
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分