前提・実現したいこと
HTMLに外部ファイルのJSを記載したのですが、
読み込んでくれません。
おそらくpathが間違ってると思うのですが、、、、
該当のソースコード
html
1<!DOCTYPE html> 2<html lang="ja" xmlns:th="http://www.thymeleaf.org" 3 xmlns:sec="http://www.thymeleaf.org/extras/spring-security4"> 4<head> 5<script type="text/javascript" src="userEdit.js"></script> 6<meta charset="UTF-8"> 7</head> 8<body onload="proc();"> 9 <div id="output"></div> 10 <div th:replace="common/globalnavi::globalnavi"></div> 11===以下略===
javascript
1 2window.onload = onLoad; 3 4function onLoad() { 5 target = document.getElementById("output"); 6 target.innerHTML = "JavaScriptが実行されました。"; 7 }
croleで出るエラーメッセージ
1GET http://localhost:8080/userEdit.js net::ERR_ABORTED 404
HTMLとjsは同じ階層に配置しています。
HTMLにjs処理をベタ書きすると動くのですが、外部ファイルにすると動作しません。

回答4件
あなたの回答
tips
プレビュー