GWT<脚本>标签未正确加载脚本>
我在 head 标签中定义了一个函数
调用一些第三方js。实际的函数是这样的:
<script>
function fbc(d, s, id)
{ var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}
</script>
稍后我想调用该函数。我通过以下方式使用 HTML 小部件来调用它:
HTML html = new HTML();
setHTML(
"<script>"+
" fbcomment(document, 'script', 'facebook-jssdk'); "+
"</script> "+
"<fb:comments width=\"600\" num_posts=\"2\" href=\"http://www.woojah.com\"></fb:comments>");
但是,它没有正确执行。任何建议都会非常有用。
I have defined in my head tag a function <script> functionX(a,b,c) ....</script>
which calls some third party js. The actual function is this:
<script>
function fbc(d, s, id)
{ var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}
</script>
and later on I want to call that function. I'm calling it using and HTML widget in the following way:
HTML html = new HTML();
setHTML(
"<script>"+
" fbcomment(document, 'script', 'facebook-jssdk'); "+
"</script> "+
"<fb:comments width=\"600\" num_posts=\"2\" href=\"http://www.woojah.com\"></fb:comments>");
However, it is not executing properly. Any advice would be very useful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 JSNI 调用外部函数更为惯用:
It is more idiomatic to call external functions using JSNI: