Dynamically created iframe used to load file triggers with firebug loading but not without

EDIT : since this problem is now “resolved” to the working point, I am looking for information on why. For correction see my comment below.

I have a web application that dynamically loads wav files dynamically (after a timeout or as directed by a user) in an iframe to start the default player to play them. The application is only for FF 2 or 3. To determine when the file is fully loaded, I hope to use the window.onload handler for the iframe. Based on https://stackoverflow.com/a/4129605/2128323 I create a new iframe every time. As long as firebug is enabled in the browser using the application, everything works fine. Without firebug, onload never works. The firebug version is 1.3.1, while I tested Firefox 2.0.0.19 and 3.0.7. Any ideas how I can get onload from iframe to run reliably when loading a wav file? Or is there another way to report a download is complete? Here is the relevant code:

HTML (only the hidden attribute is display: none;):

<div id="audioContainer" class="hidden">
</div>

JavaScript (you can also use jQuery, but innerHTML is faster than html () from what I read):

waitingForFile = true; // (declared at the beginning of closure)
$("#loading").removeClass("hidden");
var content = "<iframe id='audioPlayer' name='audioPlayer' src='" +
    /path/to/file.wav + "' onload='notifyLoaded()'></iframe>";
document.getElementById("audioContainer").innerHTML = content;

And the contents of notifyLoaded:

function notifyLoaded() {
    waitingForFile = false; // (declared at beginning of the closure)
    $("#loading").addClass("hidden");
 }

I also tried to create an iframe through document.createElement, but I found the same behavior. Onload starts every time firebug is on and never without it.

EDIT: Fixed information on how an iframe is declared, and added callback function code. No, there is no console.log.

+3
source share
3 answers

, , Firebug open ( FF 3.6.2 Mac): http://www.jsfiddle.net/Kukry/

jQuery .load() onload.

var iframe = $("<iframe/>").load(function () {
    alert("loaded");
}).attr({
    src: "http://code.jquery.com/jquery-1.4.2.min.js"
}).appendTo($("#thediv"));

, JavaScript, , .

0

Maybe you are calling some internal Firebug function like console.log ()? In this case, Firefox will throw an exception that can stop execution if Firebug is inactive.

0
source

Source: https://habr.com/ru/post/1737193/


All Articles