How to set HTML content into an iframe

前端 未结 6 1758
醉酒成梦
醉酒成梦 2020-11-28 07:16

I have a HTML string


  Hello world
 

and I wan

6条回答
  •  孤城傲影
    2020-11-28 08:11

    The innerHTML is a bit tricky especially in IE, where elements like thead are read-only and cause a lot of trouble.

    Based on the documentation on msdn you might try documentMode which provides a innerHTML property.

    myIFrame = myIFrame.contentWindow ||
        myIFrame.contentDocument.document ||
        myIFrame.contentDocument;
    myIFrame.document.open();
    myIFrame.document.write('Your HTML Code');
    myIFrame.document.close();
    

    this might only work in IE.

    • http://msdn.microsoft.com/en-us/library/ie/ms535862(v=vs.85).aspx
    • http://msdn.microsoft.com/en-us/library/ie/cc196988(v=vs.85).aspx
    • http://msdn.microsoft.com/en-us/library/ie/ms533897(v=vs.85).aspx

提交回复
热议问题