instanceof HTMLElement in IFRAME is not Element or Object?

前端 未结 1 1008
野趣味
野趣味 2020-12-10 04:42

Trying determinate DOM Element by simple check

isElement = SomeThing instanceof Element

works in main document, but not on (all?) nodes in

相关标签:
1条回答
  • 2020-12-10 05:16

    There are different javascript implementations for main document and for iframe documents ???

    Yes. The iframe has its own environment with its own globals. Try

    var iwin = ifram.contentWindow;
    idiv instanceof iwin.HTMLElement; // true
    idiv instanceof iwin.Object; // true
    
    0 讨论(0)
提交回复
热议问题