|
0
|
1 |
|
|
|
2 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
|
|
3 |
<html> |
|
|
4 |
<head> |
|
|
5 |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> |
|
|
6 |
<title>Measuring the Window and Document</title> |
|
|
7 |
|
|
|
8 |
<style type="text/css"> |
|
|
9 |
/*margin and padding on body element |
|
|
10 |
can introduce errors in determining |
|
|
11 |
element position and are not recommended; |
|
|
12 |
we turn them off as a foundation for YUI |
|
|
13 |
CSS treatments. */ |
|
|
14 |
body { |
|
|
15 |
margin:0; |
|
|
16 |
padding:0; |
|
|
17 |
} |
|
|
18 |
</style> |
|
|
19 |
|
|
|
20 |
<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" /> |
|
|
21 |
<script type="text/javascript" src="../../build/yui/yui-min.js"></script> |
|
|
22 |
|
|
|
23 |
|
|
|
24 |
<!--begin custom header content for this example--> |
|
|
25 |
<link href="assets//node.css" rel="stylesheet" type="text/css"> |
|
|
26 |
|
|
|
27 |
<!--end custom header content for this example--> |
|
|
28 |
|
|
|
29 |
</head> |
|
|
30 |
|
|
|
31 |
<body class=" yui-skin-sam"> |
|
|
32 |
|
|
|
33 |
<h1>Measuring the Window and Document</h1> |
|
|
34 |
|
|
|
35 |
<div class="exampleIntro"> |
|
|
36 |
<p>This example shows how to measure the size of the window and document.</p> |
|
|
37 |
|
|
|
38 |
|
|
|
39 |
</div> |
|
|
40 |
|
|
|
41 |
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
42 |
|
|
|
43 |
<dl id="demo" style="height: 1000px; width: 1000px"> |
|
|
44 |
<dt>Window size</dt> |
|
|
45 |
<dd class="yui-data-win">Click me to find out</dd> |
|
|
46 |
<dt>Document size</dt> |
|
|
47 |
<dd class="yui-data-doc">Click me to find out</dd> |
|
|
48 |
</dl> |
|
|
49 |
|
|
|
50 |
<script type="text/javascript"> |
|
|
51 |
YUI({base:"../../build/", timeout: 10000}).use("node", function(Y) { |
|
|
52 |
var onClick = function(e) { |
|
|
53 |
var target = e.target, |
|
|
54 |
h, w; |
|
|
55 |
|
|
|
56 |
if (target.test('dd')) { |
|
|
57 |
if (target.test('.yui-data-win')) { |
|
|
58 |
h = target.get('winHeight'); |
|
|
59 |
w = target.get('winWidth'); |
|
|
60 |
} else if (target.test('.yui-data-doc')) { |
|
|
61 |
h = target.get('docHeight'); |
|
|
62 |
w = target.get('docWidth'); |
|
|
63 |
|
|
|
64 |
} |
|
|
65 |
target.set('innerHTML', 'width: ' + w + ' height: ' + h); |
|
|
66 |
} |
|
|
67 |
}; |
|
|
68 |
|
|
|
69 |
Y.one('#demo').on('click', onClick); |
|
|
70 |
}); |
|
|
71 |
</script> |
|
|
72 |
|
|
|
73 |
<!--END SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
74 |
|
|
|
75 |
</body> |
|
|
76 |
</html> |