According to WHATWG and MDN, window.setTimeout
and window.setInterval
have the form
var handle = window.setTimeout( handler [, timeout [, arguments... ] ] );
var handle = window.setInterval( handler [, timeout [, arguments... ] ] );
Most sources say (generic) Internet Explorer doesn't support the optional arguments
.
Is there a list of browsers and versions that do and do not support it?
An example of the way to test for support would be
<html>
<head><title>test</title></head>
<body>
setTimeout: <span id="t">testing..</span><br/>
setInterval: <span id="i">testing..</span>
<script type="text/javascript">
t = window.setTimeout( // setTimeout
function (b) { // callback
document.getElementById('t').innerHTML = (b || false); // test for arg1
},
0,
true // arg1
);
i = window.setInterval( // setInterval
function (b) { // callback
document.getElementById('i').innerHTML = (b || false); // test for arg1
window.clearInterval(i);
},
0,
true // arg1
);
</script>
</body>
</html>
With expected result true
and result on failure as false
.
According to WHATWG and MDN, window.setTimeout
and window.setInterval
have the form
var handle = window.setTimeout( handler [, timeout [, arguments... ] ] );
var handle = window.setInterval( handler [, timeout [, arguments... ] ] );
Most sources say (generic) Internet Explorer doesn't support the optional arguments
.
Is there a list of browsers and versions that do and do not support it?
An example of the way to test for support would be
<html>
<head><title>test</title></head>
<body>
setTimeout: <span id="t">testing..</span><br/>
setInterval: <span id="i">testing..</span>
<script type="text/javascript">
t = window.setTimeout( // setTimeout
function (b) { // callback
document.getElementById('t').innerHTML = (b || false); // test for arg1
},
0,
true // arg1
);
i = window.setInterval( // setInterval
function (b) { // callback
document.getElementById('i').innerHTML = (b || false); // test for arg1
window.clearInterval(i);
},
0,
true // arg1
);
</script>
</body>
</html>
With expected result true
and result on failure as false
.
- 1 Since it is so easy to simply use an anonymous function to pass extra arguments and it runs everywhere, why not just use that and avoid the headaches? – Jeremy J Starcher Commented Sep 30, 2012 at 3:16
- 1 It is a question I couldn't find an actual answer to anywhere, as in, the answers assumed every version of each browser is the same, so I went to find out and decided to share. – Paul S. Commented Sep 30, 2012 at 12:45
1 Answer
Reset to default 8Using a test based upon the example code in the question and BrowserShots for the browsers, here is a table of browser support
Browser Version setTimeout setInterval
Chrome 4+ true true Lowest version testable
Firefox 3+ true true Did not test lower versions
MSIE 6 false false
MSIE 7 false false
MSIE 8 false false
MSIE 9 false false
MSIE 10 true true
Opera Not tested
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745631388a4637130.html
评论列表(0条)