Skip to content
rootscript edited this page Mar 8, 2015 · 2 revisions

Inject-HTML-and-CSS-into-iFrame - Comments/Questions:


Q:Does this work if the iFrame is on another domain?

A1:It has to be on the same domain, the browser doesn't allow to modify iframes on domains, which does not seems to be the same as the source is. A2:I think the problem is this code works when the iframe is on the SAME DOMAIN. So calling an iframe from a different domain won't be possible.


Q:Do you know how to add the syntax highlighting on the textareas? A: Use CodeMirror: http://codemirror.net/


Q-A:It would be better to set the variable styleTag using the following code:

styleTag = $('').appendTo( contents.find('head') );

I would use a method like this because you won't have to wait on jQuery to append the html (which can sometimes take a little while) before parsing.


Clone this wiki locally