How make redir into button with javascript

Hi,

I made a javascript button becouse I wanted to be sure that the user updated the form each time he wanted to exit.

var ans = confirm(“Do you want to save… ?”);
if(ans == true)
{
nm_atualiza(‘alterar’);
}

I’ve tried to insert sc_redir into if but it doesn’t work

var ans = confirm(“Do you want to save… ?”);
if(ans == true)
{
nm_atualiza(‘alterar’);
sc_redir(form_to_go, “”, “_parent”);
}

How can I do the redir after the data saving ?

Thanks