- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2020 10:51 PM
Hi ,
I am trying to close the current UI page through client script but unable to close it . Please help.
Client script Code :
function onSubmit() {
var close = confirm("Thank You for your response. Please click on 'OK' to close the page");
if (close) {
window.top.close();
}
}
Regards,
Sagaya .
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2020 07:31 AM
this won't work and is not possible.
Scripts may close only the windows that were opened by it." If your script did not initiate opening the window (with something like window. open), then the script in that window is not allowed to close it. Its a security to prevent a website taking control of your browser and closing windows.
check this link
window.close() doesn't work - Scripts may close only the windows that were opened by it
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2020 10:57 PM
Hello,
you can use this script to close the Ui Page
function cancel() {
GlideDialogWindow.get().destroy();
return false;
}
function submit() {
GlideDialogWindow.get().destroy();
return true;
}
Please Mark it as helpful/Correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2020 12:02 AM
Hi Ankush ,
Its not working
HTML Code :
<tr>
<td align='center'>
<input type="radio" name="status" value="yes" onClick="onSubmit()">Yes </input> </td>
<td align='center'><input type="radio" name="status" value="no" onClick="onSubmit()"> No </input> </td>
</tr>
Client script:
function onSubmit() {
var isstatus = document.querySelector('input[name="status"]:checked').value;
if (isstatus == 'no') {
var close = confirm("Thank You for your response. Please click on 'OK' to close the page");
if (close) {
GlideDialogWindow.get().destroy();
return false;
}
}}
Regards
Sagaya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2020 12:22 AM
Hello,
Try this updated Client script:
function onSubmit() {
var isstatus = document.querySelector('input[name="status"]:checked').value;
if (isstatus == 'no') {
var close = confirm("Thank You for your response. Please click on 'OK' to close the page");
if (close) {
GlideDialogWindow.get().destroy(); //Close the dialog window
reloadWindow(window);
}
}}
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2020 03:33 AM
Hi Sagar ,
Still its not working.
Regards,
Sagaya .