我正在尝试将 TwitterWidget 集成到 SilverStripe 中。
这就是我要使用的插件: https ://twitter.com/about/resources/widgets/widget_profile
如果我将此代码放在一个简单的 *.html 文件中,小部件就可以工作。不幸的是,如果我尝试在 *.ss 文件中使用它,则会出现错误。
我下载了源代码以找出错误发生的位置。几个小时后,我发现了一些非常令人困惑的事情:
那是发生错误的代码:
document.write('<div class="twtr-widget" id="'+this.id+'"></div>')
萤火虫:
uncaught exception: [Exception... "An attempt was made to use an object that is not, or is no longer, usable" code: "11" nsresult: "0x8053000b (NS_ERROR_DOM_INVALID_STATE_ERR)" location: "http://www.domain.com/mysite/javascript/widget.js?m=1321187964 Line: 257"]
LeftAn...8532904 (Zeile 883)
function() {return new ActiveXObject('Microsoft.XMLHTTP')},
几次刷新后,有时 FireBug 会报告:
An attempt was made to use an object that is not, or is no longer, usable
[Bei diesem Fehler anhalten] document.write('<div class="twtr-widget" id="'+this.id+'"></div>')
谷歌浏览器 JavaScript 调试器:
Uncaught TypeError: Object #<Document> has no method 'write' //widget.js:257
TWTR.Widget.init //widget.js:257
TWTR.Widget //widget.js:211
(anonymous function) //?stage=Stage&flush=1:117
f.extend._Deferred.e.resolveWith //jquery-1.6.4.min.js:2
e.extend.ready //jquery-1.6.4.min.js:2
c.addEventListener.C //jquery-1.6.4.min.js:2