FireFox 代码无法运行

发布于 2024-10-06 17:36:06 字数 448 浏览 0 评论 0 原文

Firefox 是否有任何原因不显示下面的代码? 它可以在所有其他浏览器中工作,并创建注释

(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript';  
    dsq.async = true;
    dsq.src = 'http://sample.disqus.com/embed.js';
    (document.getElementsByTagName('head')[0] || 
     document.getElementsByTagName('body')[0]).appendChild(dsq);
})();

ps 如果与 Firefox 相关的代码没有任何明显的错误,那么它一定是其他浏览器,我会继续挖掘。我在想也许他们不认识其中一个标签之类的?但我想他们会的。

is there any reason why firefox might not display this code below?
It works in every other browser and creates the comments

(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript';  
    dsq.async = true;
    dsq.src = 'http://sample.disqus.com/embed.js';
    (document.getElementsByTagName('head')[0] || 
     document.getElementsByTagName('body')[0]).appendChild(dsq);
})();

p.s. if there isn't anything obviously wrong with the code with respect to firefox it must be something else and I'll keep digging. I was thinking maybe they don't recognize one of the tags or something? But I guess they do.

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

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

发布评论

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

评论(2

习惯那些不曾习惯的习惯 2024-10-13 17:36:06

用这种方式。

<script type="text/javascript">
(function() {
var dsq = document.createElement('script');  
    dsq.async = true;
    dsq.src = 'http://sample.disqus.com/embed.js';
    (document.getElementsByTagName('head')[0] || 
     document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>

因为它与所有浏览器兼容。

use this way.

<script type="text/javascript">
(function() {
var dsq = document.createElement('script');  
    dsq.async = true;
    dsq.src = 'http://sample.disqus.com/embed.js';
    (document.getElementsByTagName('head')[0] || 
     document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>

because its compatible with all browser.

何以畏孤独 2024-10-13 17:36:06

这是一个示例: http://www.phpied.com/javascript-include-ready -onload/ 使用 setAttribute 而不是点表示法属性。也许这就是 Firefox 想要的? (没试过这个)

Here is an example: http://www.phpied.com/javascript-include-ready-onload/ that uses setAttribute instead of dot notation properties. Maybe that is what Firefox wants? (haven't tried this)

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