-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputoutfocus.js
41 lines (34 loc) · 894 Bytes
/
inputoutfocus.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function allBlur() {
var inputTags = document.getElementsByTagName("input");
var textareaInput = document.getElementsByTagName("textarea");
var textareaInputArray = Array.from(textareaInput);
var textInputs = [];
function addInput(inputType) {
if (inputType !== null) {
textInputs.push(inputType);
}
}
try {
textareaInputArray.forEach(element => {
if(element.style.display !== "hidden"){
textInputs.push(element)
}
});
for (var i = 0; i < inputTags.length; i++) {
if (inputTags[i].type === "text") {
textInputs.push(inputTags[i]);
}
}
for (var j = 0; j < textInputs.length; j++) {
textInputs[j].blur();
}
} catch (e) {
console.error(e);
}
}
document.addEventListener("visibilitychange", (event) => {
if (document.visibilityState == "visible") {
allBlur();
} else {
}
});