top.window

Rohit Agarwal
Mega Expert

Hi,

What is the use of top.window. Why top.window works in portal but window. is there any document related to this??

 

Thanks,

 

 

8 REPLIES 8

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

Docs Link

Service Portal & Client Scripts

Regards
Ankur

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

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');
	}

}

 

Can you close the thread marking correct answer ? Marking correct answer will help to understand other developers having same concerns.

-Thank you

Megha Padale
Giga Guru