Skip to content

Instantly share code, notes, and snippets.

@CaiJimmy
Last active October 21, 2021 03:44
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save CaiJimmy/84dead2d2919af05fede to your computer and use it in GitHub Desktop.
Disqus点击加载
<button id="load-disqus" onclick="disqus.load();">
加载Disqus
</button>
<div id="disqus_thread"></div>
var disqus = {
load : function disqus(){
var disqus_shortname = 'disqus';
if(typeof DISQUS !== 'object') {
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
$('#load-disqus').remove(); ///加载后移除按钮
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment