The CreatorCon Call for Content is officially open! Get started here.

Close browser tab when button is clicked

Servicenow Use4
Kilo Guru

Hello everyone!

I have a form button called 'Close'. My requirement is as follows: When the button is clicked, the browser tab should be closed. What scripting should be done for this in the UI Action, can anyone help me with this please?

Thanks in advance!

15 REPLIES 15

Jaspal Singh
Mega Patron
Mega Patron

Hi,

 

There are couple of links around this. Kindly give it a check.

Link1, Link2

Hi!

I used the following code in the UI Action script:

GlideDialogWindow.get().destroy();

it redirected me to the previous page in the same tab. How should I simply close that tab?

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

please use client side UI action

OnClick: closeWindow();

this script should work fine

Script:

function closeWindow(){

window.open('','_self').close();

}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hello Ankur, 

Thanks for the response! Can you please tell me what is written after open in this line : window.open('','_self').close();