- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 09-10-2022 07:53 PM
I guess there is some confusion regarding top, window and document objects in Native UI and Service Portal. So, sharing my observations regarding these during some testing in PDI.
function onLoad() {
if (window === null) { // For portal
//top.location.href; will work in portal
//top.window.location.href; will work in portal
//top.document.location.href; will work in portal
//window.location.href; will not work in portal because window is null in portal
//document.location.href; will not work in portal because document is null in portal
alert('Portal Top: ' + top.location.href);
alert('Portal Top.Window: ' + top.window.location.href);
alert('Portal Top.Document: ' + top.document.location.href);
alert('Document Object: ' + document);
alert('Window Object: ' + window);
alert('Top Object: ' + top);
} else { // For Native UI
//top.location.href; will work in Native UI
//top.window.location.href; will work in Native UI
//top.document.location.href; will work in Native UI
//window.location.href; will work in Native UI
//document.location.href; will work in Native UI
alert('Native UI Top: ' + top.location.href);
alert('Native UI Top.Window: ' + top.window.location.href);
alert('Native UI Window: ' + window.location.href);
alert('Native UI Top.Document: ' + top.document.location.href);
alert('Native UI Document: ' + document.location.href);
alert('Document Object: ' + document);
alert('Window Object: ' + window);
alert('Top Object: ' + top);
}
}
- Catalog Client Script Configuration:
- Catalog Client Script UI Type = All
- Isolate = False
- Execution
- If block will be executed in portal, else block will be executed in Native UI.
- Catalog Client Script Configuration:
- Catalog Client Script UI Type = All
- Isolate = True
- Execution
- If block will be executed in portal and Native UI both, else block will not be executed in portal and Native UI.
- window and document will be null, to access them top will be used.
- Catalog Client Script Configuration:
- Catalog Client Script UI Type = Desktop
- Isolate = False
- Execution
- No block will be executed in Portal, else block will be executed in Native UI.
- Catalog Client Script Configuration:
- Catalog Client Script UI Type = Desktop
- Isolate = True
- Execution
- No block will be executed in Portal, if block will be executed in Native UI.
- window and document will be null, to access them top will be used.
- Catalog Client Script Configuration:
- Catalog Client Script UI Type = Mobile / Service Portal
- Isolate = False
- Execution
- No block will be executed in Native UI, if block will be executed in Portal.
- window and document will be null, to access them top will be used.
- Catalog Client Script Configuration:
- Catalog Client Script UI Type = Mobile / Service Portal
- Isolate = True
- Execution
- No block will be executed in Native UI, if block will be executed in Portal.
- window and document will be null, to access them top will be used.
Interested in reading my other articles, go through the below link.
Useful Implementation for Service Portal and Native UI
Always open to learn new things.
Happy Learning
- 4,742 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Muhammad Khan Fantastic. Thank you.
1) So does this mean that the "document" and the "window" objects are always available via "top"?
2) Also, can this information be used to somehow reliably determine, inside the script itself, if it is running in the context of the Service Portal VS the Platform UI? If so, please explain. Thanks!