Skip to content

Commit 72a9e8f

Browse files
authored
Update script.js
1 parent 4869af6 commit 72a9e8f

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

script.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,28 @@ document.getElementById("contactForm")?.addEventListener("submit", function(e) {
22
e.preventDefault();
33
alert("Message sent! We'll get back to you soon.");
44
});
5-
5+
6+
window.onerror = function (message, source, lineno, colno, error) {
7+
console.log("Error occurred: ", message);
8+
// Redirecting based on error
9+
if (message.includes("404")) {
10+
window.location.href = "404.html";
11+
} else if (message.includes("505")) {
12+
window.location.href = "505.html";
13+
} else if (message.includes("1010")) {
14+
window.location.href = "1010.html";
15+
} else if (message.includes("303")) {
16+
window.location.href = "303.html";
17+
} else if (message.includes("606")) {
18+
window.location.href = "606.html";
19+
} else if (message.includes("707")) {
20+
window.location.href = "707.html";
21+
} else if (message.includes("808")) {
22+
window.location.href = "808.html";
23+
} else if (message.includes("909")) {
24+
window.location.href = "909.html";
25+
} else if (message.includes("202")) {
26+
window.location.href = "202.html";
27+
}
28+
return true; // Prevents the default browser error page
29+
};

0 commit comments

Comments
 (0)