通过javascript/html访问twitter共享iframe

Access twitter share iframe through javascript/html

本文关键字:twitter 共享 iframe 访问 html javascript 通过      更新时间:2023-09-26

在某些页面上,twitter共享按钮没有显示其全部宽度。我已经追踪到了这个问题,它显示的iframe只设置为24px宽度,但我需要将其设置为正确的宽度。问题是…我无法直接访问iframe,因为这是插入它的代码:

<div style="margin:4px 0 0 5px; float:left; position: relative;"><a href="https://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a></div>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div><!-- END #socialNetworking -->
<script>

有人知道我如何编辑iframe吗?生成的HTML没有显示iframe,但是深入chrome web开发工具上的HTML检查器,我可以在那里看到它:

<iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.1347008535.html#_=1347624904492&amp;count=none&amp;id=twitter-widget-0&amp;lang=en&amp;original_referer=http%3A%2F%2Fwww.dgfdg.co.uk%2F&amp;size=m&amp;text=Web%20Design%20Kendal%20%7C%20Website%20Design%20Cumbria%20%7C%20Graphic%20Design%20%7C%20Marketing%20%7C%20Advertising%20%7C%20Designworks%20%7C&amp;url=http%3A%2F%2Fwww.fdfdg.co.uk%2F" class="twitter-share-button twitter-count-none" style="width: 24px; height: 20px; " title="Twitter Tweet Button" data-twttr-rendered="true"></iframe>

查看https://dev.twitter.com/docs/tweet-button,我认为这是你想要的"大小"属性。不过,它只接受分类值。我认为你不能把它设置成任意大小。