IMG-LOGO

How to check if a function in windows parent exists in Javascript?

andy - 31 Mar, 2016 4052 Views 0 Comment

When ever you try to reference a function from parent window, always perform a check if the function itself is exist. This will ensure there is no javascript error that can cause problem loading your site content or may cause a conflict with another javascript code.

To check if a function exists in the windows parent, you can use the following code.

if (typeof parent.functionName === "function") {
	//if exists perform your code here.
}

Comments

There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.

Related Articles