The Test.js code is as follows:
var i = 0;
function Fun ()
{
document.write (i);
document.write ("\ n");
i++;
}
function Javatime ()
{
SetInterval (' Fun () ', 2000);
}
The test.php code is as follows:
<title>Untitled Document</title>
echo ""
?>
Why the JS timer executes only once, and then the browser stays in this state:
Show only 0, then the browser has been turning ...
Reply to discussion (solution)
I don't know much about JS. A change in the number of alert (i) is strange.
Landlord, you are not IE kernel browser try, such as the chrome kernel, you can get the effect you want, but the line is not \ n
[img=http://] [/IMG]
Effect
Untitled Document
You read it like that. I have no problem with the test.
Upstairs says yes, it's all nonsense!
When the page loading is complete, the document of the page's carrier will be closed
The later document.write will be written in the new document.
Although non-IE series browser only the body node as the root of document, JS is still executed on the surface, but the original contents of the body is no longer exist
So as long as the page load is completed before the execution of JS, can only use InnerHTML, innerText operation page content or alert display information