| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <!DOCTYPE html>
- <html lang="en" style="height: 100%">
- <head>
- <meta charset="utf-8">
- <title>047 script DOM and 100% height</title>
- <style>
- html { height: 100%; }
- body { min-height: 100%; margin: 0; background: #ffffff; color: #202020;
- font-family: sans-serif; }
- .spacer { height: 1700px; padding: 16px; }
- footer { height: 150px; background: #204080; color: #ffffff;
- font-size: 22px; padding: 14px; }
- .ok { background: #c8f0c8; color: #000000; padding: 8px; font-size: 18px; }
- .fail { background: #ffc8c8; color: #000000; padding: 8px; font-size: 18px; }
- </style>
- </head>
- <body>
- <div class="spacer">
- <h1>047 — script DOM and 100% height</h1>
- <p>This page is taller than the window. Press <b>End</b>: the blue footer
- must appear. The old layout measured the page against its width, so End
- stopped here instead of at the bottom.</p>
- <div id="result" class="fail">script check pending</div>
- </div>
- <footer>
- <div id="footer-text">SCROLL-FAIL</div>
- <div id="script-result">SCRIPT-PENDING</div>
- </footer>
- <script>
- setTimeout(function () {
- var scripts = document.getElementsByTagName('script');
- var styles = document.getElementsByTagName('style');
- var ok = scripts.length >= 1 && scripts[0] && scripts[0].parentNode;
- ok = ok && styles.length >= 1 && styles[0] && styles[0].parentNode;
- var r = document.getElementById('result');
- if (r) {
- r.className = ok ? 'ok' : 'fail';
- r.textContent = ok ? 'SCRIPT-OK (' + scripts.length + ' script element)'
- : 'SCRIPT-FAIL';
- }
- var sr = document.getElementById('script-result');
- if (sr) sr.textContent = ok ? 'SCRIPT-OK' : 'SCRIPT-FAIL';
- var body = document.body.getBoundingClientRect();
- var foot = document.querySelector('footer').getBoundingClientRect();
- var ft = document.getElementById('footer-text');
- if (ft) {
- ft.textContent = 'SCROLL-OK body=' + Math.round(body.height) +
- ' footer=' + Math.round(foot.top);
- }
- }, 300);
- </script>
- </body>
- </html>
|