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,605
  • 1
  • 18
  • 32
sam
  • 1
  • 1
  • 1

2 Answers2

2

Have you tried checking

if (typeof window.parent.HideWaitMessage === 'function') {
// sage to use
}
Chava Geldzahler
  • 3,605
  • 1
  • 18
  • 32
gie3d
  • 766
  • 4
  • 8
1

I would use the following protection

window.parent && typeof window.parent.HideWaitMessage === 'function'
dhilt
  • 18,707
  • 8
  • 70
  • 85