Firefox/jQuery使用Twitter Bootstrap弹出窗口的错误

Firefox/jQuery bug using Twitter Bootstrap popover

本文关键字:窗口 错误 Bootstrap jQuery 使用 Twitter Firefox      更新时间:2023-09-26

当我调用Twitter Bootstrap popover时,我使用Firefox而不是webkit浏览器收到了这个错误。

NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 0 [nsIDOMWindow.getComputedStyle] @ http://localhost/assets/thirdParty/jquery/jquery-1.8.3.js:6825

错误出现在jquery.js:的第6825行

var computed = window.getComputedStyle( elem, null );

这篇文章似乎解决了这个问题,但当我尝试实现他们的解决方案(如下所示)时,没有效果。这篇文章已经发布了4年,所以jQuery的版本不同了,我想可以解释为什么这个解决方案不再有效。

if (elem == document) elem = document.body; 
var computed = window.getComputedStyle( elem, null );

我回答了自己的问题。问题是我的popover内容以一条评论结尾。所以这不起作用:

<div class="popover">
    some content
</div><!--popover-->

而这确实发生了:

<div class="popover">
    some content
</div>