开发者

top.opener.location.reload(true) not refreshing parent page on IE

开发者 https://www.devze.com 2023-01-16 17:47 出处:网络
I have two pages, the parent and from this page I am using: window.open(\'OrderDetailsFull.aspx?ObjectID=\' + ObjectID[1] , \"TableDetails\",\"status=0 , toolbar=0 , location=no , menubar=0 , scroll

I have two pages, the parent and from this page I am using:

window.open('OrderDetailsFull.aspx?ObjectID=' + ObjectID[1] , "TableDetails","status=0 , toolbar=0 , location=no , menubar=0 , scrollbars=yes , height=600px , width=800px"); 

to open a new window and manipulate data over there.

When I finish what I am doing I need the parent page to refresh so I will get the new data data in it...

From what I know the method is: 开发者_如何学编程

top.opener.location.reload(true);

but for some reason, it is not working in IE8 or IE9...

As I am building an application and not a general web page. It will work on Windows OS with IE (as for now it is still the most common system...nothing to do about it) so I really need to solve this problem....

I couldn't find any new solution over the web for this problem, every one say it should work like that.....

Did anyone encounter this problem? and does any one knows how to solve it?

OK, FOLLOW UP question: when I do opener.location.reload(true); does it render the parent page all over again (as it sound) or not? If it does then I'm in a big problem, if not, then there must be a way to do that...

The problem is the I have an ajax call in the parent page and for some reason it stays in it's old values when I am using it, only when I reload the child window, the parent ajax shows the real results, some code follows...

This is in the document ready jQuery function of the opener page:

$('div[id^="divTable"]').hover(
        function(e){
            //קבלת זהות השולחן הנלחץ
            ObjectID = $(this).attr('id').split('_');
            $(this).css("cursor","pointer");                
            //AJAX הבאת נתוני רשומת ההזמנה מהשרת ב
             var OrderDetails = $.ajax({
                    url:'AjaxActions/OrderDetails.aspx?ObjectID=' + ObjectID[1],
                    async:false                 
                }).responseText;
             //צף מעל שולחן כשעומדים עליו, ניתן לראות את פרטי הרשומה של אותו השולחן DIV
             $(this).append($('<div style="position: absolute; top: 0; left: -150;">' + OrderDetails + '</div>'));
             //וידוא שהשולחן עליו אנו עומדים יהיה העליון
             $(this).css("z-index","10");
             $(this).siblings().css("z-index","1");
        },   
        //כשיוצאים מהשולחן DIVהעלמת ה
        function () {
                  $(this).find('div:last').remove()
        }
    );

This is in one of the functions in the child window that should refresh the opener:

    $('#ctrl_Print').click(
        function()
        {
            alert($('#hidItem').val());
            var Items = new Array(); 
            Items = $('#hidItem').val().split(',');
            for(var i=0;i<Items.length;i++)
            {
                alert(Items[i]);
            }
            opener.location.reload(true);
            window.location = 'OrderDetailsFull.aspx?OrderID=' + OrderID + '&ObjectID=' + ObjectID + '&Print=' + Items;
            window.close();
        }
    );

10x...


It looks like IE 8 and 9 have security restrictions on refreshing the opener.


I've run into this problem where reload() works in Chrome, but pukes in IE.

Try using window.location.replace(your url and params here).

You have to collect the url and params for replace(), but it gets around the IE error message.

Example:

In Joomla 2.5 parent window launches modal for users input, where we need to reload the parent window (view) in order to run code that uses modal input.

The modal fires a function in the parent window like;

function updateAddresses(runUpdate, itemID, closeModal){
        if(closeModal == true ){
           SqueezeBox.close(); 
        }

        if(runUpdate == true){
           //location.reload(); 
           var replaceURL = 'index.php?option=com_poecom&view=cart&ItemId='+itemID;
           window.location.replace(replaceURL);
        }
    }


top is used to get the outermost document within the current physical window when you're dealing with framesets and/or iframes and is not related to window.open in any way, so you shouldn't use top unless there are frames or iframes within your pop-up page. The following will do:

opener.location.reload(true);


If you want to access the parent window (or frame), you should use parent, not top:

parent.location.reload(true);

When your page is a frame inside that window, add more parents to it:

parent.parent.location.reload(true);
0

精彩评论

暂无评论...
验证码 换一张
取 消