Javascript Iframe innerHTML

后端 未结 10 2645
没有蜡笔的小新
没有蜡笔的小新 2020-11-27 07:08

Does anyone know how to get the HTML out of an IFRAME I have tried several different ways:

document.getElementById(\'iframe01\').contentDocument.body.innerHT         


        
10条回答
  •  猫巷女王i
    2020-11-27 07:59

    If you take a look at JQuery, you can do something like:

    
    
    $('#my_iframe').contents().find('html').html();
    

    This is assuming that your iframe parent and child reside on the same server, due to the Same Origin Policy in Javascript.

提交回复
热议问题