-
Notifications
You must be signed in to change notification settings - Fork 0
/
windownameb.html
134 lines (124 loc) · 4.02 KB
/
windownameb.html
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=400">
<title>window.name [b]</title>
<!-- custom -->
<style>
:root{
--test0: #b3b3b3;
--test7: #9ddc9d;
--test12: #9db2dc;
--test99: #808080;
--bg99: #808080;
}
body {background-color: #161b22; color: var(--test0);}
h2 {color: white; font-size: 14px; text-align: center; margin-top: inherit;}
a.blue {color: var(--test12); text-decoration: none;}
a.return {color: var(--test12); text-decoration: none; font-size: 14px; line-height: 1.2em}
.no_color {color: #b3b3b3;}
.mono {font-family: monospace, "Courier New";}
.good {color: var(--test7);}
.bad {color: #ff6363;}
div.nav-title {position: relative;}
table {
width: 97%; min-width: 380px; max-width: 480px;
border-collapse: collapse; margin: 0 auto 10px auto; font-size: 12px;
}
tbody:before {content: "-"; display: block; line-height: 1em; color: transparent;}
td {padding-bottom: 3px; padding-top: 3px; padding-left: 10px;}
th {color: black; font-weight: bold; font-size: 16px; padding: 3px 0;}
table td:first-child { text-align: right; vertical-align: top;}
table td.blurb {text-align: center; line-height: 1.5em;}
table td.center {text-align: center;}
table td.intro {text-align: left; line-height: 1.5em; padding-bottom: 10px;}
#tb99 th {background-color: var(--bg99);}
#tb99 td:first-child {color: var(--test99);}
.btn {background-color: #161b22;
display: inline-block;
font-size: 12px;
font-family: monospace, "Courier New";
font-weight: bold;
padding-left: 6px;
padding-right: 6px;
cursor: pointer;
}
.btn0 {border-color: var(--test0); color: var(--test0);}
.btn-left {float: left; position: relative; left: -10px; top: 0px;}
</style>
</head>
<body>
<table>
<tr><td><h2>TorZillaPrint</h2></td></tr>
<tr><td class="blurb"><a class="return" href="https://arkenfox.github.io/TZP/index.html#other">return to TZP index</a></td></tr>
</table>
<table id="tb99">
<col width="40%"><col width="60%">
<thead><tr><th colspan="2"><div class="nav-title">window.name [b]</div>
</th></tr></thead>
<tr>
<td><div class="btn-left"><span class="btn0 btn" onClick="run()">[ re-run ]</span></div>current</td>
<td class="mono" id="current"></td></tr>
<tr><td>setting new</td><td class="mono" id="setnew"></td></tr>
<tr><td>check new</td><td class="mono" id="check"></td></tr>
<tr><td>next</td>
<td><span class="no_color mono">load
<a class="blue" href="https://arkenfox.github.io/TZP/tests/windownamea.html">window.name [a]</a></span>
</td></tr>
</table>
<br>
<script>
'use strict';
var s0 = " <span class='",
sb = s0 +"bad'>",
sg = s0 +"good'>",
sc = "</span>"
function rnd_string(prefix) {
return (prefix == undefined ? "" : prefix) + Math.random().toString(36).substring(2, 15)
}
function run() {
let str = ""
let current = document.getElementById("current")
let setnew = document.getElementById("setnew")
let check = document.getElementById("check")
// clear
current.innerHTML = " "
setnew.innerHTML = " "
check.innerHTML = " "
try {
str = window.name
if (str == undefined) {str = "undefined"}
else if (str == "undefined") {str = "\"undefined\""}
else if (str == "") {str = "nothing found"}
current.innerHTML = str
} catch(e) {
current.innerHTML = e.name
}
// create a random string
str = rnd_string()
var control = str
try {
window.name = str
} catch(e) {
str = e.name
}
setnew.innerHTML = str
// read it back: set a little timer
setTimeout(function() {
let chk = ""
try {
chk = window.name
if (chk == undefined) {chk = "undefined"}
else if (chk == "undefined") {chk = "\"undefined\""}
else if (chk == "") {chk = "nothing found"}
} catch(e) {
chk = e.name
}
check.innerHTML = chk + (chk == control ? sg +"[success]": sb +"[failure]") + sc
}, 150)
}
run()
</script>
</body>
</html>