关闭子页面后,刷新父页面学习

关闭子页面后,刷新父页面,这个功能大家经常会需要用到。前两天写个项目用到这个功能,在这里记录一下,备以后使用。其实很简单,父窗口要用只需用简单的window。open函数就可以。
function OpenExcluded() {
              var left = (screen.width / 2) - 370;
              var top = (screen.height / 2) - 240;
              var targetWin = window.open('ExcludedStores.aspx', 'ExcludedStores', 'width=740,height=480,top=' + top + ',left=' + left + ',toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');

          }    

玄机都在子页面,在子页面关闭的时候,通过opener 对象获取父页面控件,然后模拟父页面刷新按钮,即调用该控件的click()事件。

       function MyClose(message) {
            if (message != '') {
                window.alert(message);
                var btn = opener.document.getElementById('ctl00_ContentPlaceHolder1_btnSearch');
                btn.click();
            }
            window.close();
            

        } 

posted @ 2011-05-24 13:38 Vincent.Tianjin 阅读(224) 评论(0) 编辑 收藏
发表评论

昵称: [登录] [注册]

主页:

邮箱:(仅博主可见)

评论内容:

  登录  注册

[使用Ctrl+Enter键快速提交评论]

0 2055383 ld6wS+BZRZE=