teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

「twitter.com/intent/tweet になったようなので」と書いておきながら、twitter.com/intent/tweet になってなかったので修正しました

2018/03/04 08:22

投稿

退会済みユーザー
answer CHANGED
@@ -19,7 +19,7 @@
19
19
  "tag3"
20
20
  ].join(",");
21
21
 
22
- window.open("https://twitter.com/share?" + [
22
+ window.open("https://twitter.com/intent/tweet?" + [
23
23
  "text=" + encodeURIComponent(text),
24
24
  "url=" + encodeURIComponent(url),
25
25
  "hashtags=" + encodeURIComponent(hashtags)

2

window.openの使い方を修正しました

2018/03/04 08:22

投稿

退会済みユーザー
answer CHANGED
@@ -19,9 +19,9 @@
19
19
  "tag3"
20
20
  ].join(",");
21
21
 
22
- window.open().location.href = "https://twitter.com/share?" + [
22
+ window.open("https://twitter.com/share?" + [
23
23
  "text=" + encodeURIComponent(text),
24
24
  "url=" + encodeURIComponent(url),
25
25
  "hashtags=" + encodeURIComponent(hashtags)
26
- ].join("&");
26
+ ].join("&"));
27
27
  ```

1

encodeURIComponentを追加しました

2018/03/04 08:12

投稿

退会済みユーザー
answer CHANGED
@@ -20,8 +20,8 @@
20
20
  ].join(",");
21
21
 
22
22
  window.open().location.href = "https://twitter.com/share?" + [
23
- "text=" + text,
23
+ "text=" + encodeURIComponent(text),
24
- "url=" + url,
24
+ "url=" + encodeURIComponent(url),
25
- "hashtags=" + hashtags
25
+ "hashtags=" + encodeURIComponent(hashtags)
26
26
  ].join("&");
27
27
  ```