Nicolae Rotaru
Nicolae Rotaru

Reputation: 189

html 'inception' cross browser issue

I have to show a preview of a html code (an entire html page which of course starts with html tag ...etc) from a textarea,using iframe. It works in webkit browsers but not in firefox.

Textarea:

<textarea id="document_token_body">the source code of a html page here</textarea>

The preview area:

<iframe id="result" width="680px" frameborder="0"></iframe>

and javascript code:

document.getElementById('result').contentWindow.document.documentElement.innerHTML = document.getElementById('document_token_body').value;

Upvotes: 2

Views: 248

Answers (1)

Kijewski
Kijewski

Reputation: 26043

Try contentDocument instead of contentWindow.document.

Works for me in Firefox 20: http://jsfiddle.net/7vyDa/

Upvotes: 2

Related Questions