【发布时间】:2013-06-13 13:33:53
【问题描述】:
我正在使用 Meteor 开发一个应用程序。我正在尝试在我的一个表单上使用 reCaptcha,并在我的某些页面上使用 Disqus cmets 系统。但问题是,当我运行流星服务器时,这些都没有呈现。
这是我添加到模板中的示例 Disqus 代码:
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'HIDDENfromstackoverflow'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
为此,网页上仅显示“cmets powered by Disqus”文字。
对于验证码:
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=HiddenFromStackOverflow"
height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>
有趣的是,如果我在浏览器中将模板作为普通 HTML 文件打开(而不是通过 Meteor 服务器),则会显示 reCaptcha。
我错过了什么?
【问题讨论】:
-
我认为将js脚本放入模板不是一个好主意。放入head标签中。
-
但 disqus 和验证码需要将脚本放置在您希望它们显示的位置。
-
@Siddharh Gupta:你确定元素在你网站的 DOM 中吗?尝试使用一些网络检查器(firefox 中的 firebug 等)并查看元素是否真的在 DOM 中或流星是否忽略它们
标签: javascript meteor recaptcha disqus meteorite