简体   繁体   中英

Access twitter share iframe through javascript/html

On some pages the twitter share button is not showing its full width. I have traced the problem, the iframe in which it is displayed is only set to 24px width, however i need to set it to the correct width. Problem is.. I have no access to the iframe directly since this is the code to insert it:

<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>

Does anybody know how I can edit the iframe? The generated HTML does not show the iframe, however digging into the html inspector on chrome web dev tools, i can see it there:

<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>

Look at https://dev.twitter.com/docs/tweet-button , I think it's the "size" attribute you're looking for. It only accepts categorical values, though. I don't think you can set it to some arbitrary size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM