top.window

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2020 05:00 AM
Hi,
What is the use of top.window. Why top.window works in portal but window. is there any document related to this??
Thanks,
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2020 05:22 AM
Hi Rohit,
As per the docs window object won't work in portal.
check below links for more details on what is supported and what is not
Service Portal & Client Scripts
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
08-21-2020 05:26 AM
both are java-script method,
as folks already mentioned about the window, it will not support on portal. it has not documented regarding the top,
as per my understanding window is not reachable by client script and it will return null
But if you will use top.window you can access the object variable ( "The top property is useful if the current document is placed within a subframe (a frame within a frame) and you need to access the topmost ancestor window.")
To test it , you can run below client side script.
function onLoad() {
//Type appropriate comment here, and begin script below
top.window.com = 'testing';
alert(window + top.window);
if(com == 'not'){
alert('if block');
}
else{
alert('else block');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2020 10:46 AM
Can you close the thread marking correct answer ? Marking correct answer will help to understand other developers having same concerns.
-Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2020 06:21 AM
Hi Rohit,
Check below links
If my answer helped you in any way, mark answer as helpful and correct.
Thanks and regards,
Megha.