質問編集履歴
4
修正
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
Fetch APIを使って書き換えましたが、まだ表示されません。エラーはないです。
|
|
70
70
|
```JS
|
|
71
71
|
window.addEventListener('DOMContentLoaded', function () {
|
|
72
|
-
fetch('loader.html')
|
|
72
|
+
fetch('/assets/include/index-loader.html')
|
|
73
73
|
.then(response => response.text())
|
|
74
74
|
.then(data => {
|
|
75
75
|
const parser = new DOMParser();
|
|
76
76
|
const html = parser.parseFromString(data, "text/html");
|
|
77
|
-
const p_elements = html.
|
|
77
|
+
const p_elements = html.getElementsByClassName('loader')[0];
|
|
78
|
-
const file_area = document.getElementsByClassName("loader");
|
|
78
|
+
const file_area = document.getElementsByClassName("loader")[0];
|
|
79
79
|
file_area.innerHTML = p_elements.innerHTML;
|
|
80
80
|
});
|
|
81
81
|
});
|
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
</div>
|
|
98
98
|
</body>
|
|
99
99
|
```
|
|
100
|
+
これでできたのですが、Ajaxより若干もたつくのはどうにかならないのでしょうか。
|
|
100
101
|
|
|
101
102
|
### 補足情報(FW/ツールのバージョンなど)
|
|
102
103
|
Firefox 最新版、XAMPP、Safari 604.1
|
3
修正
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
</head>
|
|
91
91
|
<body>
|
|
92
92
|
<!-- loader -->
|
|
93
|
-
<div class="
|
|
93
|
+
<div class="loader">
|
|
94
94
|
<svg>
|
|
95
95
|
<rect x="50" y="20" rx="20" ry="20" width="150" height="150" style="fill:red;stroke:black;stroke-width:5;opacity:0.5">
|
|
96
96
|
</svg>
|
2
修正
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -91,9 +91,11 @@
|
|
|
91
91
|
<body>
|
|
92
92
|
<!-- loader -->
|
|
93
93
|
<div class="index-loader">
|
|
94
|
+
<svg>
|
|
94
95
|
<rect x="50" y="20" rx="20" ry="20" width="150" height="150" style="fill:red;stroke:black;stroke-width:5;opacity:0.5">
|
|
95
|
-
|
|
96
|
+
</svg>
|
|
96
97
|
</div>
|
|
98
|
+
</body>
|
|
97
99
|
```
|
|
98
100
|
|
|
99
101
|
### 補足情報(FW/ツールのバージョンなど)
|
1
修正
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -66,5 +66,35 @@
|
|
|
66
66
|
### 試したこと
|
|
67
67
|
ネイティブJSでのインクルードについて調べましたが、めぼしい記事はありませんでした。エラー出ていないけれどどうして読み込まれないのでしょうか。
|
|
68
68
|
|
|
69
|
+
Fetch APIを使って書き換えましたが、まだ表示されません。エラーはないです。
|
|
70
|
+
```JS
|
|
71
|
+
window.addEventListener('DOMContentLoaded', function () {
|
|
72
|
+
fetch('loader.html')
|
|
73
|
+
.then(response => response.text())
|
|
74
|
+
.then(data => {
|
|
75
|
+
const parser = new DOMParser();
|
|
76
|
+
const html = parser.parseFromString(data, "text/html");
|
|
77
|
+
const p_elements = html.querySelector('.loader');
|
|
78
|
+
const file_area = document.getElementsByClassName("loader");
|
|
79
|
+
file_area.innerHTML = p_elements.innerHTML;
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
include
|
|
84
|
+
```HTML
|
|
85
|
+
<!DOCTYPE html>
|
|
86
|
+
<html lang="ja">
|
|
87
|
+
<head>
|
|
88
|
+
<meta charset="utf-8">
|
|
89
|
+
<title>test</title>
|
|
90
|
+
</head>
|
|
91
|
+
<body>
|
|
92
|
+
<!-- loader -->
|
|
93
|
+
<div class="index-loader">
|
|
94
|
+
<rect x="50" y="20" rx="20" ry="20" width="150" height="150" style="fill:red;stroke:black;stroke-width:5;opacity:0.5">
|
|
95
|
+
</svg>
|
|
96
|
+
</div>
|
|
97
|
+
```
|
|
98
|
+
|
|
69
99
|
### 補足情報(FW/ツールのバージョンなど)
|
|
70
100
|
Firefox 最新版、XAMPP、Safari 604.1
|