Page redirection and close the window are not working in firefox

I wrote the following code to redirect the user to different pages and close the window. While the following code works fine in chrome, but it does not work in firefox.

function OnRequestComplete(result) {
            if (result != null) {
                window.returnValue = true;
                var myhref = '';
                myhref = result;
                window.opener.top.location.href = myhref;
                window.close();
                }
        }