I am using a child window to perform some action and trying to pass some parameters if error occurs. The problem is that, the parameters in the URL keep on stacking, I want to remove all parameters of the parent window via child window so that it only shows the parameters added newly.
Code I'm using right now:
window.opener.location.reload(false);
window.opener.location.href.replace(/&status=[^&;]*/,'');
window.opener.location.href.replace(/&error_code=[^&;]*/,'');
if (window.ammendError) {
window.opener.location.href += "&status=error&error_code=" + window.ammendErrorCode;
}
window.close();
In this code, its adding the status
and error_code
parameter. But its not removing the previous parameters from URL.