I have a simple for loop inside jQuery but it is not working fine in Firefox.
Problem: It writes my variable fine but if you look at the Firefox tab it says
Connecting…
all the time.
Also if I check my script with Firebug it says:
No Javascript on this page
although it writes my variable.
What I am doing wrong here? Fiddle here
$(document).ready(function(){
var i=0;
for(i=0;i<=3;i++) {
document.write(i);
}
//alert("working");
});
Never use write() after the document has finished loading, it will overwrite the complete document(including scripts)
But however, when the issue is the fact that the (new)document didn’t finish the loading-process in your example, call
document.close()afterdocument.write()http://jsfiddle.net/f2jFc/3/