Window.safari undefined inside iframe

I have a page that should access window.safari.pushNotification . Everything works fine when you load this page. However, when this page is included in the iframe window.safari not undefined .

This problem occurs even if you are on the same origin and even add

 sandbox="allow-forms allow-popups allow-pointer-lock allow-same-origin allow-scripts allow-top-navigation" 

does not solve the problem.

Is this supposed behavior or error? Is there any window.safari accessing window.safari from inside the iframe? (I really need it)

To reproduce this question is simple. Just add the following code to the page and try:

  • download it directly
  • include it in another page using iframe
 window.addEventListener('load', function () { console.log('safari' in window) }); 
+9
javascript safari iframe
source share

No one has answered this question yet.

See similar questions:

nineteen
window.open (url, '_blank'); not working on iMac / Safari

or similar:

2709
Undefined object property detection
2660
Closing JavaScript internal loops is a simple practical example.
2597
How to check empty string / undefined / null in JavaScript?
2131
How to check "undefined" in JavaScript?
2038
Is there a standard function for checking null, undefined or empty variables in JavaScript?
1957
How to determine if a variable is "undefined" or "null"?
960
How to apply CSS to iframe?
763
jQuery / JavaScript: accessing iframe content
143
How to access parent iframe from JavaScript

All Articles