'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();
                }
        }


Solution 1:[1]

use this for redirection:

        window.location.href = myhref;

If you want to close a window on firefox, use this:

top.window.close()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Huan Le