I cannot close a tab(tab) with javascript

Asked

Viewed 355 times

1

My universe is as follows:

The attendant is with an open guide, making, obviously, a service. To end this service, URA already starta a second service. Turns out IVR opens another tab. By closing this service, this guide is not closed and if the URA opens another, will be open as many guides as the URA open. It would have to come manually closing, and at least one tab should be open, due to the login, ie the first tab. What happens is that the IVR is an external agent, so this tab(page) opened cannot be controlled by the tab that is open, because it was not the one who opened it. I would like to make a code (javascript) that closes the tab in question. I’ve tried to:

parent.self.close();
window.close();
self.close();

Anyway, there were several attempts and none worked. The guide does not close.

We use ASP Classic and Javascript.

    <script defer language="javascript">
                    if (window.ActiveXObject) {
                        window.open('ace002c.asp?/cal/asp/cal0087b.asp$$$pt=Atendimento&pcf=ATB0082&num_associado=<%=num_associado%>&ind_origem_consulta=A&statusAtendimento=A&vinculacao=beneficiario&origem=CALLCENTER&tipo_atendimento_beneficiario=N', 'JANELA', 'top=0,left=0'); 
                    }
                    else {
                        alert(3);                       
                        sessionStorage.setItem("URL_ATENDIMENTO_URA", true); 
                         window.open("ace002c.asp?/cal/asp/cal0087b.asp$$$pt=Atendimento&pcf=ATB0082&num_associado=<%=num_associado%>&ind_origem_consulta=A&statusAtendimento=A&vinculacao=beneficiario&origem=CALLCENTER&tipo_atendimento_beneficiario=N", '_blank');                  
}

//open(location, '_self').close();
                    //alert(12);
                    //debugger;
                    window.onbeforeunload = null;
                    //console.log('teste1');
                    parent.self.close();
                    //alert(13);
                </script

>

And this code below, I simulate URA:

http://teste.dev.amil.com.br/ace/iniciaAtendimento.asp?protocolo=326338

Pages are opened within FRAMES(Iframe). This system is a legacy here in the company.

When I use the _self, it carries the information and closes itself(parent.self.close()), but do not skip the user screen. What should be done is that the attendance screen should be poped, regardless of which screen is open by the user, usually it is not open when closing a call. I did it that way with _self.

window.open("ace002c.asp?/cal/asp/cal0087b.asp$$$pt=Atendimento&pcf=ATB0082&num_associado=<%=num_associado%>&ind_origem_consulta=A&statusAtendimento=A&vinculacao=beneficiario&origem=CALLCENTER&tipo_atendimento_beneficiario=N", '_self');
  • What is the code to open new guides? you want me to close from inside the tab or controlling from outside the tab?

  • Try window.open(Location, '_self'). close(); Which browser/version is using ?

  • @Mauroalexandre, Chrome

  • It didn’t work either. Important information was missing and I will edit the post.

  • In IE it works. Why? Well, in IE it is possible to name windows and in this way, I believe that IE uses its internal mechanisms to locate these windows and thus close them, open them and etc. Chrome does not have this concept as I understood.

1 answer

1

I don’t know if it is possible to close it directly, but one option is to find iframe by its ID/class on the page that contains it and then remove it.

parent.document.getElementById("id_do_iframe").remove()
  • Emoon, it didn’t work that way either. I did a quick search and everyone said that what I’m looking for at Chrome is not possible.

  • In my last Dit, I understood that Chrome does not open the answering screen, because the IVR simulates a second person, that is, this other tab was opened not from inside the open tab, but by another external element, in the case the IVR, so the screen does not stern.

  • If you can change the call script on the call screen you could use window.location.replace("http//xxx.com.br") and even within a timer, for example: setTimeout(Function () { window.location.replace("http//xxx.com.br"); }, 1000).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.