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. }