Many methods provided on the Internet are implemented by judging whether the current window and the top window are the same. The code is as follows if(top!=this){
// Process when in frame
}
But this script does not distinguish between frame and iframe.
I encountered a strange problem under IE when using scripts: the page is normal only in the problematic iframe frame. And it works fine in Firefox and Chrome. I no longer want to comment on IE. Finally, I found a method on MSDN to determine whether the current page is in an iframe. The script is as follows:
if(self.frameElement.tagName=="IFRAME"){
// Processed when the page is in an iframe
}