Problem with Close and Refresh function

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
mchaggis
Forum Contributor
Posts: 150
Joined: Mon Mar 24, 2003 10:31 am
Location: UK

Problem with Close and Refresh function

Post by mchaggis »

Hi,

I have the following function which I use when popup windows are closed (that have been used to edit the data).

Code: Select all

function CloseRefresh() {
        window.opener.location.reload();
        window.close();
}
This function of course works a charm. Until of course the parent page was loaded with the post method and you get the annoying message asking if you want to post data again.

The following change to the function, seems to combat this:

Code: Select all

function CloseRefresh() {
        window.opener.location=window.opener.location;
        window.close();
}
Although, it would appear that if a page is loaded using the standard get method, it doesn't always do anything, more than likely due to browsers being a bit too clever.

What I'd like to do is develop a hybrid, something like the following:

Code: Select all

function CloseRefresh() {
        if (window.opener.requestmethod=='post') {
                window.opener.location=window.opener.location;
        } else {
                window.opener.location.reload();
        }

        window.close();
}
Anyone have any ideas?

Cheers
Post Reply