我的代码在 Firefox 中不起作用...?
我有这段代码似乎可以在 chrome 和 safari 中工作(不确定 Opera 和 ie.. 只是还没有测试过..),但在 Firefox 中它至少不会重复播放功能,而是只运行一次。
HTML:
<div class="Start">Play</div><div class="Stop">Stop</div>
<br /><br />
<p>Lorem Ipsum Dolor Sit Amet...</p>
JS:
var myTimeOut, Stop, stop_flag;
$('.Start').click( function () {
stop_flag = 0;
Repeat();
});
$('.Stop').click( function () {
clearTimeout(Stop);
stop_flag = 1;
$('p').show('slow');
});
function Repeat() {
if(stop_flag == 1)
{
return;
}
else
{
$('p').show('slow').delay(400).hide('slow', function() {Stop = setTimeout(Repeat(), 1100)});
}
}
问题是..任何想法为什么不是在火狐浏览器中工作
I have this code that seems to work in chrome and safari ( not sure about opera and ie.. just havent tested.. ) but in firefox it at least doesnt repeat the play function but just runs it once.
HTML:
<div class="Start">Play</div><div class="Stop">Stop</div>
<br /><br />
<p>Lorem Ipsum Dolor Sit Amet...</p>
JS:
var myTimeOut, Stop, stop_flag;
$('.Start').click( function () {
stop_flag = 0;
Repeat();
});
$('.Stop').click( function () {
clearTimeout(Stop);
stop_flag = 1;
$('p').show('slow');
});
function Repeat() {
if(stop_flag == 1)
{
return;
}
else
{
$('p').show('slow').delay(400).hide('slow', function() {Stop = setTimeout(Repeat(), 1100)});
}
}
Question is.. any ideas why it is not working in firefox
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你应该说:
注意缺少的括号。目前,您告诉它调用由
Repeat()
返回的函数,当然没有。You should be saying:
Note the missing brackets. At the moment you're telling it to call the function returned by
Repeat()
, which of course there isn't.不知道为什么 Firefox 是唯一一个抱怨的,但你的 setTimeout 写错了。应该是:
Not sure why firefox is the only one conmplaining but you've written your setTimeout wrong. It should be:
你的问题是这个
变化:
至:
请参阅此处的工作示例:
http://jsfiddle.net/ZL5XN/1/
You problem is this
Change:
To:
See the working example here:
http://jsfiddle.net/ZL5XN/1/