iframe content not appear - javascript

I have this code and sometimes works and sometimes not:
var urlThemes2="../usuarios/"+parent.parent.parent.Nb_Global_usuario+"/aplicaciones/"+parent.parent.parent.Nb_Global_aplicacion+"/appfiles/includes/themes/";
alert("preview")
$("#listaTemas2").attr("src","Nb_ListaTemas.php?urlThemes="+urlThemes2);
In the Chrome's inspector shows the iframe's "src" defined, but not the html content.
Any solution?
Thanks,

Related

Iframe content not loading in firefox

I have iframe in my pop up. the content of iframe's set by
$('.document-acceptance-container .documentIframe')
.contents()
.find('body')
.html(this.model.get('data').DocumentRecord.DocumentBodyPath);
It work's fine in Chrome and content of iframe is loaded, but in firefox iframe is empty. I set
security.mixed_content.block_active_content to false and disabled addblock.
But it didn't help me.If I set a breakpoint on this line in debug mode in firefox - content was loaded.
Have you any idea?
P.S: DocumentRecord.DocumentBodyPath is html code

Setting content of iframe using javascript fails in firefox

I'm trying to set the content of a iframe using javascript.
I've the html string. And I'm writing:-
var iframe = $('iframe')[0],
content = '<div>test</div>';
$(iframe).contents().find('html').html(content);
It works fine in google chrome, but in firefox is shows the content for a moment and the disappears.
Please help me to fix it.
I faced the same problem. I saw the load function of iframe fires in firefox but not in chrome. So firefox reload the iframe again on load event.
So with your existing code try this:-
$(iframe).load(function(e){
$(iframe).contents().find('html').html(content);
})

Sandbox iframe attribute isn't preventing redirects in FIrefox

I'm trying to get iFrame sandboxing to work, and Firefox is giving me trouble.
<iframe src="" scrolling="no" sandbox=""></iframe>
I use jQuery to set the iFrame's src attribute to one of several different pages. But my target pages have JavaScript in them that makes them break out of my iFrame. I counter that with the sandbox attribute, which is supposed to prevent JavaScript from running inside the iFrame. This works great in Chrome and Internet Explorer, but in Firefox as soon as I load the target page into the iFrame it takes over the whole window.
Firefox's documentation says it fully supports the sandbox attribute. Am I doing something wrong? Installing NoScript and telling my browser not to run JavaScript from the target site makes everything work fine, but obviously I don't want Firefox users to have to install an addon before my site will work.
If you are manipulating or setting the sandbox attribute after the iframe is in the DOM, it will completely ignore the setting. You must set it before the iframe element is added to the DOM.

location.hash inside iframe not working on Firefox

I'm trying to display an HTML5 slideshow inside an iframe (based on Google's html5slides). The current slide number is set in the URL hash to be able to directly jump to it.
But it doesn't work in Firefox. The tricky part is that I populate the iframe's content using javascript, so my iframe doesn't have a src attribute. When I load my slideshow's code in the iframe, it is correctly displayed on Chrome, Opera, Safari, even IE9. But on Firefox it loads for a split second then loads my parent page inside the iframe.
I suspect that setting the hash inside the iframe doesn't work in firefox because I have no src attribute (I tested with an empty src attribute and it's the same)
So is there another way to set the url's hash of an iframe in javascript that would work with firefox?
You can see the bug in firefox if you paste this page content's in jsbin.com with real-time preview: http://html5slides.googlecode.com/svn/trunk/template/index.html
In firefox jsbin will load itself inside the preview iframe.

Dynamic iframe not loaded occasionally in Firefox

I have some JavaScript code that dynamically injects an iframe in a given HTML page. Unfortunately, in Firefox, and only in Firefox, although the iframe is created from time to time the relevant URL isn't loaded into it.
I know it wasn't loaded because the relevant URL doesn't appear in the Firebug Net tab, and when I inspect the iframe I don't see any expected HTML code in there (when the iframe is on the same domain as the outlying page). I don't see any JavaScript or network errors either.
Here's a code snippet, I've checked all the relevant variables are correct:
var iframe = document.createElement("iframe");
iframe.width = options["w"];
iframe.height = options["h"];
iframe.scrolling = "no";
iframe.marginWidth = 0;
iframe.marginHeight = 0;
iframe.frameBorder = 0;
iframe.style.borderWidth = 0;
if (node.childNodes.length > 0)
node.insertBefore(iframe, node.childNodes[0]);
else
node.appendChild(iframe);
iframe.contentWindow.location = iframeSrc + "?" + querystring;
Here's an example URL that is set for the iframe (the issue also recreates when the URL points to an external server, had to omit the 'http://' at the beginning otherwise I couldn't post the question):
127.0.0.1:8000/widget/iframe/index.html?style=slide-top-to-bottom&culture_code=en_us&c=26&sc=1324&title=Top%20News&caption=Top%20Stories&order=relevance&count=20&w=250&h=300&timestamp=true&scrollbar=false&theme=ui-lightness&className=8815455464592103&referrer=http%3A%2F%2F127.0.0.1%3A8000%2Fwidget%2Fbuilder%2Findex.html
Doing some research on the web, I found this unfixed Firefox bug which seems related to this issue:
https://bugzilla.mozilla.org/show_bug.cgi?id=279048
After reading the bug, I tried several solutions none of which solved the issue:
Setting iframe.src instead of iframe.contentWindow.location
Adding a random parameter to the querystring
Adding the '#' symbol with a random number at the end of the URL
Giving the iframe a random name
Does anyone have a workaround for this annoying Firefox bug? Or is the issue I'm describing unrelated to the bug and has a different solution?
What happens if you add this to the bottom of your script?
iframe.contentWindow.location.reload(true);
Perhaps it will stop the need to reload in FF.
EDIT
Fixed the example
Solved the issue, I was looking in the wrong place. The HTML file where this dynamic iframe was loaded had an empty iframe tag that was removed from the DOM, after which the dynamic iframe was injected instead.
Apparently Firefox cached the last URL for this iframe, and loaded it immediately as the external page loaded. I know because I saw the relevant HTML file being loaded twice in the Firebug Net tab rather than once upon the injection.
After I got rid of this empty iframe tag and relied only on the injected iframe, everything started to work well and the issue didn't reproduce anymore. I guess Firefox didn't like handling this scenario, some kind of bug maybe?
Thanks anyway for helping me out, it gave me the inspiration for the right solution :)

Categories

Resources