Disqus: Universal Code Fix

7 October 2014

As I found, when using the current universal code on Disqus the script will not load in IE 10 (and possibly below). However, the script will load on all other browsers.

The script currently makes an "Access is Denied" error on the console of IE, this can be solved by using an AJAX call instead. As demonstrated below:

JS
<div id="disqus_thread"></div>
<script type="text/javascript">
	/* CONFIGURATION VARIABLES */
	var disqus_shortname = '****';
	/* CHANGE THIS BLOCK OF CODE BELOW FOR FIX */
	(function() {
		if (typeof(disqus_loaded)=="undefined" || !disqus_loaded) {
		  disqus_loaded=1;
		  jQuery.ajax({
		    type: 'GET',
		    url: 'http://' + disqus_shortname + '.disqus.com/embed.js',
		    dataType: 'script',
		    cache: true
		  });
		}
    })();
</script>

By using this code Disqus will now load for all browsers including IE 10. Hope this helps somebody!

Comments

comments