0

I am trying to append some html code into iframe body and head, it works everywhere but mozilla.

var thisSlide = jQuery("#slide_1264");
var thisIframe = thisSlide.find("iframe");

var html = thisSlide.find(".template_layout").clone();

var iframeBody = thisIframe.contents().find("body");

iframeBody.append(html);

var iframeHead = thisIframe.contents().find("head");

iframeHead.append("<link rel='stylesheet' href='/scripts/ckeditor/contents.css' type='text/css'>");
iframeHead.append("<link rel='stylesheet' href='/css/template_style.css' type='text/css'>");

It does not return and console error, and basically it should just take html content from changing div "slide_?" and put it into iframe.

Is it some basic bug in mozilla? And should i look for some workaround? Or my code intepretation is not suited for mozilla browser?

user3175393
  • 109
  • 1
  • 10
  • http://stackoverflow.com/questions/6494721/css-override-body-style-for-content-in-iframe – Lalji Tadhani Sep 15 '15 at 10:44
  • Seems like for you, mozilla hasn't finished loading the iframe before you start meddling with it. wrap your code in a setTimeout (5000 ms should do) just to confirm ... then you'll have to figure out how to wait until the **iframe** has loaded before you start messing with it's innards :p – Jaromanda X Sep 15 '15 at 11:11
  • What is not working ? The thisSlide.find(".template_layout") is not cloned, or the iframeBody returns an empty jQuery object ? Please do not consider Jaromanda answer, as putting arbitrary timeout like this is always a bad idea. – Stranded Kid Sep 15 '15 at 12:26

0 Answers0