0

This snippet check if the current page is in a iframe. The code works well in normal navigation mode but not in incognito mode on Chrome when domains of parent page and iframe are different (ex: localhost and localhost1). In incognito mode always show 'NORMAL' alert message.

if( window.top === window.self){
    alert('NORMAL') 
} else { 
    alert('IFRAME')
}

How can I make it work in incognito mode?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
ar099968
  • 6,963
  • 12
  • 64
  • 127
  • It works fine for me in incognito. – Unmitigated Mar 09 '23 at 14:37
  • This related post has some other options available: [how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe](https://stackoverflow.com/questions/326069/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t) specifically the answer by **Konstantin Smolyanin** – Ryan Wilson Mar 09 '23 at 14:38
  • I've update the question specifying that domains should be cross origin – ar099968 Mar 09 '23 at 15:00

0 Answers0