The following way to call setInterval seems to work in Firefox 3.5 and Chromium 10.0 but not in Firefox 4.
var setInterval;
(function runmenow () {
setInterval(function () { document.write('hello<br /&g开发者_JAVA技巧t;'); }, 1000);
}());
Firebug tells me that "setInterval is not a function". Why isn't setInterval available in this context?
This (i believe) is because you are setting setInterval as null in that first line.
just do:
//var setInterval; <--remove
(function runmenow () {
setInterval(function () { document.write('hello<br />'); }, 1000);
}());
精彩评论