0

I am currently working on a web forms application. I have Javascript function [e.g HideWaitMessage() ] in the parent window. I use window.parent.HideWaitMessage() from child window to access this and it works as expected.

However, in order to avoid errors, I wanted to verify whether the function does exist in the parent window. Please advise on how I can achieve this.

Chava Geldzahler
  • 3,423
  • 1
  • 15
  • 31
sam
  • 1
  • 1

2 Answers2

2

Have you tried checking

if (typeof window.parent.HideWaitMessage === 'function') {
// sage to use
}
Chava Geldzahler
  • 3,423
  • 1
  • 15
  • 31
gie3d
  • 688
  • 4
  • 7
1

I would use the following protection

window.parent && typeof window.parent.HideWaitMessage === 'function'
dhilt
  • 15,987
  • 7
  • 58
  • 75