Skip to content

Commit a596bb2

Browse files
author
jdev082
committed
feat: added page that is loaded when URL cannot be loaded
Signed-off-by: jdev082 <jdev082@jdev.eu.org>
1 parent 70f2eeb commit a596bb2

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

src/fail.html

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Failed to load page</title>
7+
<link rel="stylesheet" href="../styles.css">
8+
</head>
9+
<body>
10+
<style>
11+
* {
12+
margin: 0 !important;
13+
}
14+
div {
15+
margin-left: 48pt !important;
16+
margin-top: 48pt !important;
17+
}
18+
</style>
19+
<div id="title">
20+
<h1>This page could not be loaded.</h1>
21+
<p>This could be caused by the following:</p>
22+
</div>
23+
<div id="list">
24+
<ul>
25+
<li>No internet connection.</li>
26+
<li>Bad network connection.</li>
27+
<li>The page is down.</li>
28+
<li>The URL was not typed correctly.</li>
29+
<li>Your computer has invalid DNS settings.</li>
30+
</ul>
31+
</div>
32+
</body>
33+
</html>

src/search.js

-5
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ function loadURL(url, scheck='true') {
7878
return;
7979
}
8080
view.src = url;
81-
view.addEventListener('did-fail-load', () => {
82-
view.src = 'home.html';
83-
alert(`Failed to load page ${url}`);
84-
return;
85-
});
8681
}
8782
removeChildren(suggestionsEl);
8883
view.addEventListener('did-finish-load', () => {

src/tabs.js

+3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ function addListeners(view, hash) {
144144
tab.getElementsByTagName('img')[0].style.display = 'none';
145145
}
146146
});
147+
view.addEventListener('did-fail-load', (e) => {
148+
view.src = './fail.html'
149+
});
147150
}
148151

149152
function removeTab() {

0 commit comments

Comments
 (0)