File: document_write.html

package info (click to toggle)
elinks 0.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 24,296 kB
  • sloc: ansic: 174,602; cpp: 31,967; sh: 7,841; python: 4,039; perl: 2,183; javascript: 1,794; pascal: 1,710; makefile: 1,006; yacc: 295; lisp: 125; awk: 79; ruby: 70
file content (66 lines) | stat: -rw-r--r-- 1,528 bytes parent folder | download | duplicates (3)
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
<html>
<head>
<title>
-| 16 colors |-
</title>
<script type="text/javascript">
  function lpad_str(str) {
    if (str.length<=9) { str=(str+"    ").slice(-9); }
    return str;
  }
  function lpad(number) {
    if (number<=999) { number = ("00"+number).slice(-3); }
    return number;
  }
  function printstr(item,index) {
    if ((index)%4==0) { document.writeln("<tr>"); }
    document.write('<td>');
    document.write('<font color="'+item+'">'+lpad_str(item) +'</font> ');
    document.write('<td>');
    if ((index+1)%4==0) { document.writeln("</tr>"); }
  }
  function printstrln(item,index) {
    document.writeln('<font color="'+item+'">'+lpad(index)+' This is '+item+'</font>');
  }


function onl()
{

document.writeln('<html><head><title>-| 16 colors |-</title></head><pre>');
  var colors=[
    "white",
    "maroon",
    "green",
    "yellow",
    "blue",
    "magenta",
    "cyan",
    "white",
    "grey",
    "red",
    "lime",
    "olive",
    "teal",
    "purple",
    "fuchsia",
    "aqua",
  ];

  document.write('<table>');
  colors.forEach(printstr);
  document.write('</table>');
  document.writeln('<br>');
  colors.forEach(printstrln);

  document.writeln('');
  document.writeln('<font color="yellow">This is true     : '+true+'</font>');
  document.writeln('<font color="red">and this is false: '+false+'</font>');
  document.writeln('<font color="yellow">',"That's it as ... ","1+1=",2,'</font>');
  document.writeln('</pre></body></html>');
}
</script>
</head>
<body onload="onl()">
</body>
</html>