質問編集履歴

4

解決方法追記

2019/03/19 08:52

投稿

unee
unee

スコア17

test CHANGED
File without changes
test CHANGED
@@ -42,9 +42,9 @@
42
42
 
43
43
  ```html
44
44
 
45
- <a href="javascript:window.location.href='https://www.xxxxxx.com/'+Id_01;" target="_blank">
45
+ <a href="javascript:window.location.href='https://www.xxxxxx.com/'+Id_01;" target="_blank"></a>
46
46
 
47
- <a href="javascript:window.location.href='https://www.xxxxxx.com/'+Id_02;" target="_blank">
47
+ <a href="javascript:window.location.href='https://www.xxxxxx.com/'+Id_02;" target="_blank"></a>
48
48
 
49
49
  ```
50
50
 
@@ -91,3 +91,41 @@
91
91
 
92
92
 
93
93
  よろしくお願いいたします。
94
+
95
+
96
+
97
+ ### 実現方法
98
+
99
+ ```JavaScript
100
+
101
+ $(function(){
102
+
103
+ var ua = navigator.userAgent;
104
+
105
+ if ((ua.indexOf('iPhone') > 0 || ua.indexOf('Android') > 0) && ua.indexOf('Mobile') > 0){
106
+
107
+         $('.id=01').attr('href','https://www.xxxxxx.com/mobile/activity/xxxxx?event_id=01');
108
+
109
+         $('.id=02').attr('href','https://www.xxxxxx.com/mobile/activity/xxxxx?event_id=02');
110
+
111
+ } else if (ua.indexOf('iPad') > 0 || ua.indexOf('Android') > 0){
112
+
113
+         $('.id=01').attr('href','https://www.xxxxxx.com/mobile/activity/xxxxx?event_id=01');
114
+
115
+         $('.id=02').attr('href','https://www.xxxxxx.com/mobile/activity/xxxxx?event_id=02');
116
+
117
+ } else {
118
+
119
+         $('.id=01').attr('href','https://www.xxxxxx.com/mobile/activity/xxxxx?event_id=01');
120
+
121
+         $('.id=02').attr('href','https://www.xxxxxx.com/mobile/activity/xxxxx?event_id=02');
122
+
123
+ }
124
+
125
+ });
126
+
127
+ ```
128
+
129
+ この方法で思っていました動きは実現しました。
130
+
131
+ 効率の良い方法、これから勉強したいと思います。

3

誤字

2019/03/19 08:52

投稿

unee
unee

スコア17

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  var Id_01 = mobile/activity/xxxxx?event_id=01;
14
14
 
15
-    var Id_01 = mobile/activity/xxxxx?event_id=02;
15
+    var Id_02 = mobile/activity/xxxxx?event_id=02;
16
16
 
17
17
  } else if (ua.indexOf('iPad') > 0 || ua.indexOf('Android') > 0) {
18
18
 

2

誤字

2019/03/19 06:26

投稿

unee
unee

スコア17

test CHANGED
File without changes
test CHANGED
@@ -2,39 +2,33 @@
2
2
 
3
3
  ```javascript
4
4
 
5
- $(function() {
5
+ $(function () {
6
6
 
7
- //ユーザーの端末で条件分岐
7
+ var ua = navigator.userAgent;
8
8
 
9
- $(window).scroll(function () {
9
+ if ((ua.indexOf('iPhone') > 0 || ua.indexOf('Android') > 0) && ua.indexOf('Mobile') > 0) {
10
10
 
11
- var ua = navigator.userAgent;
11
+ // スマートフォン用処理
12
12
 
13
- if (ua.indexOf('iPhone') &gt; 0 || ua.indexOf('iPod') &gt; 0 || ua.indexOf('Android') &gt; 0
13
+ var Id_01 = mobile/activity/xxxxx?event_id=01;
14
14
 
15
- &amp;&amp; ua.indexOf('Mobile') &gt; 0) {
15
+    var Id_01 = mobile/activity/xxxxx?event_id=02;
16
16
 
17
- // スマホ用の処理
17
+ } else if (ua.indexOf('iPad') > 0 || ua.indexOf('Android') > 0) {
18
18
 
19
- var Id_01 = mobile/activity/xxxxx?event_id=01;
19
+ // タブレット用の処理
20
20
 
21
-                 var Id_01 = mobile/activity/xxxxx?event_id=02;
21
+ var Id_01 = mobile/activity/xxxxx?event_id=01;
22
22
 
23
- } else if (ua.indexOf('iPad') &gt; 0 || ua.indexOf('Android') &gt; 0) {
23
+ var Id_02 = mobile/activity/xxxxx?event_id=02;
24
24
 
25
- // タブレット用の処理
25
+ } else {
26
26
 
27
- var Id_01 = mobile/activity/xxxxx?event_id=01;
27
+     // それ以外PC用
28
28
 
29
- var Id_01 = mobile/activity/xxxxx?event_id=02;
29
+ var Id_01 = schedule/xxxxx?event_id=01;
30
30
 
31
- } else {
32
-
33
-             // それ以外PC用
34
-
35
- var Id_190410 = schedule/xxxxx?event_id=01;
36
-
37
- var Id_190410 = schedule/xxxxx?event_id=02;
31
+ var Id_02 = schedule/xxxxx?event_id=02;
38
32
 
39
33
  }
40
34
 

1

書式の改善

2019/03/19 06:25

投稿

unee
unee

スコア17

test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,5 @@
1
+ # 実現したいこと,試したこと
2
+
1
3
  ```javascript
2
4
 
3
5
  $(function() {
@@ -52,12 +54,6 @@
52
54
 
53
55
  ```
54
56
 
55
- > https://teratail.com/questions/73341
56
-
57
- 上記を参考にいたしました。
58
-
59
-
60
-
61
57
  ・モバイル&タブレット
62
58
 
63
59
  https://www.xxxxxx.com/mobile/activity/xxxxx?event_id=01
@@ -86,6 +82,16 @@
86
82
 
87
83
 
88
84
 
85
+
86
+
87
+ ### 参考
88
+
89
+ > https://teratail.com/questions/73341
90
+
91
+ 上記を参考にいたしました。
92
+
93
+
94
+
89
95
  何かもっと効率の良い方法がありましたらご教示ください。
90
96
 
91
97