How can I insert all the stylesheets of the parent window into the iframe (samedomain) head?
My code based on a similar question:
function () { var d = frames[0].document; var stylesheets = $("link").outerhtml; d.open(); d.write( '<html><head>'+ stylesheets + '<style type="text/css">'+ '<\/style><\/head><body><\/body><\/html>' ); d.close(); }
Obviously this does not work outside of IE. Thanks in advance.
Edit: an attempt based on Anthony's answer:
$("link[type='text/css']").each(function() { var stylesheet = $(this).clone(); $("iframe").contents().find("head").append(stylesheet); });
javascript jquery iframe wysiwyg
Mark
source share