質問編集履歴
1
編集後のコード
test
CHANGED
File without changes
|
test
CHANGED
@@ -103,3 +103,107 @@
|
|
103
103
|
---
|
104
104
|
|
105
105
|
説明が足りないところがあるかもしれませんがよろしくお願いします。
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
---追記
|
110
|
+
|
111
|
+
```javascript
|
112
|
+
|
113
|
+
function tenki_search() {
|
114
|
+
|
115
|
+
target2 = document.getElementById('search');
|
116
|
+
|
117
|
+
target2.innerHTML = '<iframe id="forecast_embed" type="text/html" frameborder="0" height="245" width="100%" src="http://forecast.io/embed/#lat=35.689487&lon=139.691706&name=Tokyo&units=si"></iframe>';
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
function hanasu() {
|
124
|
+
|
125
|
+
target = document.getElementById('hennji');
|
126
|
+
|
127
|
+
textbox1 = document.forms.fm2.id_textbox1.value;
|
128
|
+
|
129
|
+
var tenki1 = '天気';
|
130
|
+
|
131
|
+
var tenki2 = '今日の天気';
|
132
|
+
|
133
|
+
var tenki3 = 'てんき';
|
134
|
+
|
135
|
+
var search_tenki1 = '天';
|
136
|
+
|
137
|
+
var search_tenki2 = '気';
|
138
|
+
|
139
|
+
if (textbox1 == tenki1 || textbox1 == tenki2 || textbox1 == tenki3) {
|
140
|
+
|
141
|
+
target.innerHTML = '<iframe id="forecast_embed" type="text/html" frameborder="0" height="245" width="100%" src="http://forecast.io/embed/#lat=35.689487&lon=139.691706&name=Tokyo&units=si"></iframe>';
|
142
|
+
|
143
|
+
} else if (textbox1 == search_tenki1 || textbox1 == search_tenki2) {
|
144
|
+
|
145
|
+
target.innerHTML = '<p>もしかして<a onclick="tenki_search()" style="background-color :#ffff00;" href="javascript:void(0);">今日の天気</a></p>';
|
146
|
+
|
147
|
+
} else {
|
148
|
+
|
149
|
+
target.innerHTML = '<p>お答えできません。</p>';
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
```html
|
158
|
+
|
159
|
+
<!DOCTYPE html>
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
<head>
|
164
|
+
|
165
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
166
|
+
|
167
|
+
<script type="text/javascript" src="../js/main.js"></script>
|
168
|
+
|
169
|
+
<title> わーい</title>
|
170
|
+
|
171
|
+
</head>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
<body>
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
<FORM name="fm2">
|
180
|
+
|
181
|
+
<div class="cp_iptxt">
|
182
|
+
|
183
|
+
<input size="20" type="text" name="Z" style="background:#ffffff;" name="textbox" id="id_textbox1">
|
184
|
+
|
185
|
+
<input type="button" value="送信" onclick="hanasu()" class="btn btn-primary">
|
186
|
+
|
187
|
+
<p>返事</p><br>
|
188
|
+
|
189
|
+
<div id="hennji">ここに表示されます。</div>
|
190
|
+
|
191
|
+
<!--<div id="hennji">
|
192
|
+
|
193
|
+
-->
|
194
|
+
|
195
|
+
<div id="search_1"></div>
|
196
|
+
|
197
|
+
</div>
|
198
|
+
|
199
|
+
</div>
|
200
|
+
|
201
|
+
</FORM>
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
<!-- --------------------------------- -->
|
206
|
+
|
207
|
+
</body>
|
208
|
+
|
209
|
+
```
|