contentDocument for an iframe

前端 未结 3 1443
盖世英雄少女心
盖世英雄少女心 2020-11-29 09:18

What exactly does \"contentDocument\" represent for an iframe (or even the old \"frame\" element)? Is it equivalent to the \"html\" element or the \"body\" element ? What is

3条回答
  •  青春惊慌失措
    2020-11-29 10:20

    contentDocument represents the document of an iframe (DOM object). It is not equivalent to html since documents have their own properties, however if you type:

    myFrame.contentDocument.body 
    

    You will get the body itself.

    It is supported in all the browsers, with a tiny modification: for Internet Explorer use

    myFrame.contentWindow.document
    

    Enjoy, Nili

提交回复
热议问题