开发者

FireFox code not working

开发者 https://www.devze.com 2023-01-29 04:30 出处:网络
is there any reason why firefox might not display this code below? It works in every other browser and creates the comments

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.


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.


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消