fbjs setInnerFBML在Safari中不起作用
您好,我在使用fbjs和动态创建div时遇到问题,然后使用appendChild将其附加到现有div 举个例子:fbjs setInnerFBML在Safari中不起作用,safari,fbjs,Safari,Fbjs,您好,我在使用fbjs和动态创建div时遇到问题,然后使用appendChild将其附加到现有div 举个例子: var count = 0; function addDiv(){ var theDiv = document.createElement('div'); theDiv.setId(count); theDiv.setInnerFBML('some html here'); count++; document.getElementById(
var count = 0;
function addDiv(){
var theDiv = document.createElement('div');
theDiv.setId(count);
theDiv.setInnerFBML('some html here');
count++;
document.getElementById('someExistingDiv').appendChild(theDiv);
}
有人能告诉我使用setInnerFBML时appendChild inSafari有什么问题吗。当使用setTextValue时,这种方法非常有效
另外,它可以在Firefox中使用,但不能在Safari中使用(具体是Safari 4.0.3)
谢谢
更新:
它在附加的第一个div上工作,但在之后失败。事实证明,这是一个尚未修复的已知错误。现在,我创建了一个解决方案,并将其发布在这里,以供将来参考 由于setInnerFBML处理第一个追加,但之后失败(不知道为什么),我决定克隆追加的第一个div,并将其用于将来的追加。这是我的密码
var count = 0;
function addDiv(){
if(count == 0){
var theDiv = document.createElement('div');
theDiv.setInnerFBML('some html here');
}else{
var theDiv = document.getElementById('0').cloneNode(true);
}
theDiv.setId(count);
count++;
document.getElementById('someExistingDiv').appendChild(theDiv);
}
希望这对其他人有所帮助。setInnerFBML只接受预渲染的FBML,因此它必须来自FBML ajax请求,或者在fb:js字符串标记中预渲染。它不能动态生成