回答編集履歴

3

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

2018/03/04 08:22

投稿

退会済みユーザー
test CHANGED
@@ -40,7 +40,7 @@
40
40
 
41
41
 
42
42
 
43
- window.open("https://twitter.com/share?" + [
43
+ window.open("https://twitter.com/intent/tweet?" + [
44
44
 
45
45
  "text=" + encodeURIComponent(text),
46
46
 

2

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

2018/03/04 08:22

投稿

退会済みユーザー
test CHANGED
@@ -40,7 +40,7 @@
40
40
 
41
41
 
42
42
 
43
- window.open().location.href = "https://twitter.com/share?" + [
43
+ window.open("https://twitter.com/share?" + [
44
44
 
45
45
  "text=" + encodeURIComponent(text),
46
46
 
@@ -48,6 +48,6 @@
48
48
 
49
49
  "hashtags=" + encodeURIComponent(hashtags)
50
50
 
51
- ].join("&");
51
+ ].join("&"));
52
52
 
53
53
  ```

1

encodeURIComponentを追加しました

2018/03/04 08:12

投稿

退会済みユーザー
test CHANGED
@@ -42,11 +42,11 @@
42
42
 
43
43
  window.open().location.href = "https://twitter.com/share?" + [
44
44
 
45
- "text=" + text,
45
+ "text=" + encodeURIComponent(text),
46
46
 
47
- "url=" + url,
47
+ "url=" + encodeURIComponent(url),
48
48
 
49
- "hashtags=" + hashtags
49
+ "hashtags=" + encodeURIComponent(hashtags)
50
50
 
51
51
  ].join("&");
52
52