fbjs setInnerFBML 在 Safari 中不起作用

发布于 2024-08-12 18:04:08 字数 561 浏览 3 评论 0原文

您好,我在使用 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('someExistingDiv').appendChild(theDiv);
}

任何人都可以告诉我在使用 setInnerFBML 时出了什么问题,或者 Safari 中的appendChild 是否有任何问题。使用 setTextValue 时效果非常好。

PS 它可以在 Firefox 中工作,但不能在 Safari 中工作(具体来说是 Safari 4.0.3)

谢谢

更新:

它可以在附加的第一个 div 上工作,但在之后失败

Hi I am having problems using fbjs and creating a div dynamically and then using appendChild to append it to an existing div.

heres an example:

var count = 0;
function addDiv(){
    var theDiv = document.createElement('div');
    theDiv.setId(count);
    theDiv.setInnerFBML('some html here');

    count++; 
    document.getElementById('someExistingDiv').appendChild(theDiv);
}

can anyone please tell me whats wrong or if there are any issue with appendChild inSafari when using setInnerFBML. This works perfectly fine when using setTextValue.

P.S It works it Firefox but not in Safari (Safari 4.0.3 to be specific)

Thanks

UPDATE:

it worked on the first div appended and failed after

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

难理解 2024-08-19 18:04:08

setInnerFBML 仅接受预渲染的 FBML,因此它必须来自 FBML ajax 请求或在 fb:js-string 标记中预渲染。它不能即时生成。

setInnerFBML only takes pre-rendered FBML, so it either has to come from a FBML ajax request or be prerendered in a fb:js-string tag. It cannot be generated on the fly.

吃素的狼 2024-08-19 18:04:08

事实证明,这是一个尚未修复的已知错误。现在我创建了一个解决方法,并将其发布在这里以供将来参考。

由于 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);
}

希望这对某人有帮助。

It turned out that this was a known bug that has yet to be fixed. For now I created a workaround and Im posting it here for future references.

Since setInnerFBML worked on the first append and failed after (no idea why), I've decided to clone the first div appended and use it for future appends. Heres my code.

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);
}

Hope this helps someone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文