为什么我得到这个无限的呼叫周期? [英] Why I get this infinite-calling-cycle?

查看:130
本文介绍了为什么我得到这个无限的呼叫周期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码



<$ < / script>< p><
< a id =renderPIhref =javascript:void(0);> Render Plugin< / a>
$ b $('#renderPI')。click(function(){
new TWTR.Widget({
version:2,
type:'profile',
rpp:4,
间隔:30000,
宽度:650,
高度:202,
主题:{
shell:{
背景:'#7ee1fc',
颜色:'#2e2e2e'
},
tweets:{
background:'#ffffff',
color:'#949494 ',
links:'#009ece'
}
},
特征:{
滚动条:true,
循环:false,
vlive:false,
hashtags:true,
timestamp:true,
avatars:false,
behavior:'all'
}
})。render ().setUser('google').start();
});

当我尝试渲染Twitter Widget时,如果您检查JS控制台,您会看到奇怪的bahaviour !为什么?而且我该如何修复它?

编辑看起来问题只在Firefox上?我得到了大量的试图在一个清除的范围消息上运行编译后的脚本...

解决方案叽叽喳喳小部件使用 document.write 语句。在加载的页面上执行 document.write 清空文档,因此出现错误 - 演示这里。我的两分钱:FireFox做的是正确的。



解决方法是告诉TWTR小部件避免使用document.write,而使用DOM操作。只需创建一个空的DIV,并将其ID作为 id 参数传递给TWTR小部件 - demo here


This is my code :

<script type="text/javascript" src="http://widgets.twimg.com/j/2/widget.js"></script>
<a id="renderPI" href="javascript:void(0);">Render Plugin</a>

$('#renderPI').click(function () {
    new TWTR.Widget({
        version: 2,
        type: 'profile',
        rpp: 4,
        interval: 30000,
        width: 650,
        height: 202,
        theme: {
            shell: {
                background: '#7ee1fc',
                color: '#2e2e2e'
            },
            tweets: {
                background: '#ffffff',
                color: '#949494',
                links: '#009ece'
            }
        },
        features: {
            scrollbar: true,
            loop: false,
            vlive: false,
            hashtags: true,
            timestamp: true,
            avatars: false,
            behavior: 'all'
        }
    }).render().setUser('google').start();    
});

when I try to render the Twitter Widget, if you check the JS console, you see the strange bahaviour! Why? And how can I fix it?

EDIT Seems the problem is only on firefox? I get tons of attempt to run compile-and-go script on a cleared scope message...

解决方案

The twitter widget uses document.write statements. Doing a document.write on a page that is loaded empties the document hence the error -- demo here. My two cents: FireFox is doing the right thing.

The workaround is to tell the TWTR widget to avoid document.write and instead use DOM manipulation. Just create an empty DIV and pass its id as the id parameter to the TWTR widget -- demo here.

这篇关于为什么我得到这个无限的呼叫周期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆