File: rangetest.html

package info (click to toggle)
html2canvas 0.5.0~beta4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 920 kB
  • ctags: 416
  • sloc: makefile: 52
file content (37 lines) | stat: -rw-r--r-- 990 bytes parent folder | download | duplicates (2)
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
<!DOCTYPE html>
<html>
  <head>
    <title>Range tests</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style>
      #tests {
        font-family:Arial;
      }
      </style>
  </head>
  <body>
    <div id="tests"></div>
    <script>
      var div = document.getElementById("tests"), item, range, textNode, bounds;

      for (var i = 6; i < 72; i++) {
        item = document.createElement("div");
        item.style.fontSize = i + "px";
        item.style.lineHeight = (10 + i * 2) + "px";
        textNode = document.createTextNode(i);
        item.appendChild(textNode);
        div.appendChild(item);

        range = document.createRange();
        range.setStart(textNode, 0);
        range.setEnd(textNode, i.toString().length);
        bounds = range.getBoundingClientRect();

        textNode.nodeValue += " " + bounds.height + " " + bounds.bottom + (i % 3 === 0);

      }

    </script>
    <script src="test.js"></script>
  </body>
</html>