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

質問編集履歴

3

エラーメッセージの追加

2018/11/30 02:05

投稿

takahiro00
takahiro00

スコア84

title CHANGED
File without changes
body CHANGED
@@ -28,5 +28,9 @@
28
28
  target.innerHTML = "JavaScriptが実行されました。";
29
29
  }
30
30
  ```
31
-
31
+ ```croleで出るエラーメッセージ
32
+ GET http://localhost:8080/userEdit.js net::ERR_ABORTED 404
33
+ ```
34
+ ![イメージ説明](c3b4e33e4bd1e3ec6c0deaf58cec229a.png)
32
- HTMLとjsは同じ階層に配置しています。
35
+ HTMLとjsは同じ階層に配置しています。
36
+ HTMLにjs処理をベタ書きすると動くのですが、外部ファイルにすると動作しません。

2

ソースを詳しく

2018/11/30 02:05

投稿

takahiro00
takahiro00

スコア84

title CHANGED
File without changes
body CHANGED
@@ -11,9 +11,13 @@
11
11
  <html lang="ja" xmlns:th="http://www.thymeleaf.org"
12
12
  xmlns:sec="http://www.thymeleaf.org/extras/spring-security4">
13
13
  <head>
14
+ <script type="text/javascript" src="userEdit.js"></script>
14
15
  <meta charset="UTF-8">
15
- <script type="text/javascript" src="userEdit.js"></script>
16
16
  </head>
17
+ <body onload="proc();">
18
+ <div id="output"></div>
19
+ <div th:replace="common/globalnavi::globalnavi"></div>
20
+ ===以下略===
17
21
  ```
18
22
  ```javascript
19
23
 

1

ソース追加

2018/11/27 13:53

投稿

takahiro00
takahiro00

スコア84

title CHANGED
File without changes
body CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  ### 該当のソースコード
8
8
 
9
- ```javascript
9
+ ```html
10
10
  <!DOCTYPE html>
11
11
  <html lang="ja" xmlns:th="http://www.thymeleaf.org"
12
12
  xmlns:sec="http://www.thymeleaf.org/extras/spring-security4">
@@ -15,4 +15,14 @@
15
15
  <script type="text/javascript" src="userEdit.js"></script>
16
16
  </head>
17
17
  ```
18
+ ```javascript
19
+
20
+ window.onload = onLoad;
21
+
22
+ function onLoad() {
23
+ target = document.getElementById("output");
24
+ target.innerHTML = "JavaScriptが実行されました。";
25
+ }
26
+ ```
27
+
18
28
  HTMLとjsは同じ階層に配置しています。