LoginSignup
2
2

More than 5 years have passed since last update.

ブラウザに配置したボタンからツイートだけできるシンプルなコード片

Posted at

本当に超シンプルで、ボタンを押してツイートするだけの用途です。

事前に書きたいことをメモしたい時もあるので、textarea をボタン下に配置しています。

data-text="xxx" でボタン押下後のデフォルトメッセージを設定しておけます。

data-hashtag="xxx" で同じくボタン押下後のデフォルトハッシュタグを設定しておけます。

tweet_button.html
<!DOCTYPE html>
<html>
<head>
<title>tweet_button</title>
</head>
<body>
<a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-text="write here" data-hashtags="now_working">tweet</a>
<br><textarea cols=40 rows=5></textarea>
<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="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
</script>
</body>
</html>

意志の弱い自分は、集中を持続したい仕事中とかに、今はタイムラインは見ないけどメモ用途の tweet だけしておきたい。という願望があって、画面隅にこれをちっさく置いて使っていたりします。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2