- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html lang="en" xml:lang="en">
- <head>
- <meta charset="utf-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
- <title>Dynamic Scaling Example</title>
- <style>
- body { padding: 0; margin: 0; overflow: hidden;
- background-color: #999; position: absolute; zoom: 1;}
- #zoomWrap { width: 800px; height: 600px; min-width: 800px;
- min-height: 600px; background-color: #fff; padding: 0px;
- margin: 0px; position: relative; border: 0px}
- #contents { position: absolute; width:100%; height: 100%; top: 0px;
- left: 0px; right: 0px;}
- #zoomWrap {
- -moz-transform-origin: 0px 0px;
- -o-transform-origin: 0 0;
- -webkit-transform-origin: 0px 0px;
- -moz-transform: scale(1);
- -o-transform: scale(1);
- -webkit-transform: scale(1);
- -webkit-transform-style:preserve-3d;
- transform: scale(1);
- }
- </style>
- <script type="text/javascript" src="js/EventHelpers.js"></script>
- <script type="text/javascript" src="js/cssQuery-p.js"></script>
- <script type="text/javascript" src="js/jcoglan.com/sylvester.js"></script>
- <script type="text/javascript" src="js/cssSandpaper.js"></script>
- <script>
- var ie = false;
- </script>
- <!--[if IE]>
- <script> ie = true; </script>
- <link href="css/ie.css" rel="stylesheet" type="text/css">
- <![endif]-->
- <script>
- var contentWidth = 800;
- var contentHeight = 600;
- var pageWidth = 0;
- var pageHeight = 0;
- var addEvent = function(elem, type, eventHandle) {
- if (elem == null || elem == undefined) return;
- if ( elem.addEventListener ) {
- elem.addEventListener( type, eventHandle, false );
- } else if ( elem.attachEvent ) {
- elem.attachEvent( "on" + type, eventHandle );
- }
- };
- addEvent(window, "resize", scaleContent);
- addEvent(window, "load", scaleContent);
- function scaleContent() {
- getPageWidthHeight();
- var zoomX = (pageWidth * 1.0) /contentWidth;
- var zoomY = (pageHeight * 1.0) / contentHeight;
- var effectiveZoom = 1.0;
- var zoomWrap = document.getElementById('zoomWrap');
- var contents = document.getElementById('contents');
- var scaledContentHeight = contentHeight;
- var scaledContentWidth = contentWidth;
- if (zoomX < zoomY) {
- effectiveZoom = zoomX;
- scaledContentHeight = contentHeight * effectiveZoom;
- scaledContentWidth = contentWidth * effectiveZoom;
- var yShift = (pageHeight - scaledContentHeight)/2;
- zoomWrap.style.top = yShift + "px";
- zoomWrap.style.left = 0 + "px";
- } else if (zoomX > zoomY) {
- effectiveZoom = zoomY;
- scaledContentHeight = contentHeight * effectiveZoom;
- scaledContentWidth = contentWidth * effectiveZoom;
- var xShift = (pageWidth - scaledContentWidth)/2;
- zoomWrap.style.left = xShift + "px";
- zoomWrap.style.top = 0 + "px";
- } else {
- effectiveZoom = zoomY;
- }
- if (ie != true) {
- cssSandpaper.setTransform(zoomWrap, "scale(" + effectiveZoom + ")");
- zoomWrap.width = scaledContentWidth;
- zoomWrap.minWidth = scaledContentWidth;
- zoomWrap.height = scaledContentHeight;
- zoomWrap.minHeight = scaledContentHeight;
- contents.width = scaledContentWidth;
- contents.height = scaledContentHeight;
- } else {
- zoomWrap.filters.item("DXImageTransform.Microsoft.Matrix").M11 = effectiveZoom;
- zoomWrap.filters.item("DXImageTransform.Microsoft.Matrix").M22 = effectiveZoom;
- var newCss = 'filter: progid:DXImageTransform.Microsoft.Matrix(sizingMethod="auto expand", M11=';
- newCss += effectiveZoom + ', M12=0, M21=0, M22=' + effectiveZoom + '); ';
- newCss += '-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=' + effectiveZoom + ', M12=0, M21=0, M22=' + effectiveZoom;
- newCss += ', SizingMethod=\'auto expand\')"';
- zoomWrap.cssText = newCss;
- }
- }
- function getPageWidthHeight() {
- if (typeof window.innerWidth != 'undefined')
- {
- pageWidth = window.innerWidth,
- pageHeight = window.innerHeight
- }
- else if (typeof document.documentElement != 'undefined'
- && typeof document.documentElement.clientWidth !=
- 'undefined' && document.documentElement.clientWidth != 0)
- {
- pageWidth = document.documentElement.clientWidth,
- pageHeight = document.documentElement.clientHeight
- }
- else
- {
- pageWidth = document.getElementsByTagName('body')[0].clientWidth,
- pageHeight = document.getElementsByTagName('body')[0].clientHeight
- }
- }
- </script>
- </head>
- <body>
- <div id="zoomWrap">
- <div id="contents">
- <!-- Your absolute positioned content here -->
- </div>
- </div>
- </body>
- </html>