如何在HTML中嵌入Twitter时间线小部件

时间:2015-05-13 11:31:17

标签: html twitter

我正在尝试显示我网站的推特时间表。我已经从https://twitter.com/settings/widgets创建了一个小部件。 twitter给我一个代码来嵌入我的html文件。这是代码

  <a class="twitter-timeline" href="https://twitter.com/alamin0611" data-widget-id="598420614932779008">Tweets by @alamin0611</a> 
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s) [0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> 

但它只显示Tweets by @alamin0611。我搜索了很多但没有运气。请告诉我解决方案。

2 个答案:

答案 0 :(得分:1)

在脚本标签中,如果我删除https://它可以按预期工作,您更改了此url platform.twitter.com/widgets.js。

像这样:

<a class="twitter-timeline" href="https://twitter.com/alamin0611" data-widget-id="598420614932779008">Tweets by @alamin0611</a> 
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s) [0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> 

答案 1 :(得分:0)

<a class="twitter-timeline" data-width="300" data-height="400" href="https://twitter.com/TwitterDev">Tweets by TwitterDev</a> 

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

my first answer in forum :)