English 中文(简体)
与Jquery有关的问题,在Facebookiframe内设定间隔
原标题:Problem with Jquery, setInterval inside a Facebook iframe

I m 建立一个简单的Face tab。 我有两条表格,每3秒更换一次,在用户与用户互动之前,用固定间隔和JQuery的帮助。 他们取消开关。

$(document).ready(function() {  

    $( #item2 ).hide();
    $( li#tab1 ).addClass( selected );

    var timer = setInterval(function () {
        $( div.item ).fadeToggle( fast )
        $( li.tab ).toggleClass( selected ) ;
    }, 3000);   


    $(window).blur(function(){
        clearInterval(timer)
    })

    // setup. Set the first tab to selected
    $( li.tab ).click(function(event) {
        clearInterval(timer);
        $( li.tab ).toggleClass( selected ) 
        $( div.item ).fadeToggle( fast )
    });

});

罚款......主要是罚款。 当我把注意力放在一页(2-3分钟)和回头上时,便会出现问题,在回到正常状态之前,制片回头并 fast。 如果国家情报和安全局与以下机构有联系,我就能够解决这个问题:

$(window).blur(function(){
    clearInterval(timer)
})

which just stops the switch altogether. But this does not work when the page is inside a iframe on Facebook. Can anyone suggest a solution?

最佳回答

使用固定时间而不是固定间隔。

function doStuff(){
    //do some stuff
    setTimeout(doStuff, timeout);
}

setTimeout(doStuff, timeout);

这样,你就只能有一次电传,因此,当用户转回网页时,就会立即爆发(非常快地通知他)。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签