I can not close a tab (tab) with javascript

0

My universe is as follows:

The clerk has an open guide, obviously making a call. At the end of this service, the URA already starts a second service. It turns out that the URA opens another tab. When closing this service, this guide is not closed and if the URA opens another, it will be open as many guides as the URA open. It would have to come manually by closing, and at least one tab should remain open due to login, ie the first tab. What happens is that the URA is an external agent, so this open page can not be controlled by the guide that is open because it was not the one that opened it. I would like to make a code (javascript) that would close the tab in question. Already tried:

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

Anyway, it was 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 the 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 _self , it loads the information and closes itself ( parent.self.close() ), but does not pop up the user's screen. What should be done is that the answering screen must be popped, regardless of which screen is open by the user, usually it is not open when closing a call. I did this 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');
    
asked by anonymous 03.11.2016 / 21:48

1 answer

0

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

parent.document.getElementById("id_do_iframe").remove()
    
03.11.2016 / 23:01