내용 :
소스 :
- JS와 jQuery의 window,document 위치/크기관련된 프로퍼티를 비교 해봤습니다.
소스 :
-
<!DOCTYPE HTML>
-
<html>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
<title>Untitled Document</title>
-
<style>
-
body
-
{
-
margin:0;
-
padding:0;
-
}
-
-
#main
-
{
-
border:1px dotted #ff0000;
-
width:500px;
-
margin:50px;
-
}
-
#rect
-
{
-
border:10px solid #ff0000;
-
position:fixed;
-
left:120px;
-
top:100px;
-
}
-
-
</style>
-
-
<script type="text/javascript"
-
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js">
-
</script>
-
-
<script>
-
//http://www.w3.org/TR/cssom-view/#the-screen-interface
-
//http://www.quirksmode.org/dom/w3c_cssom.html
-
//http://debugjung.tistory.com/292
-
$(function()
-
{
-
var rect;
-
var main;
-
var nSW=5;
-
-
rect =$("#rect");
-
main =$("#main");
-
-
showInfo();
-
-
createData();
-
startMove();
-
-
function createData()
-
{
-
var strInfo="";
-
for(var i=0;i<100;i++)
-
{
-
strInfo+=i+"<br>";
-
}
-
-
main.html(strInfo);
-
}
-
-
function showInfo()
-
{
-
var strInfo="";
-
strInfo ="$(window).width(), window.innerWidth = "+window.innerWidth+"<br>";
-
strInfo +="$(window).height(), window.innerHeigh = "+window.innerHeight+"<br>";
-
strInfo +="window.outerWidth = "+window.outerWidth+"<br>";
-
strInfo +="window.outerHeight = "+window.outerHeight+"<br>";
-
strInfo +="window.pageXOffset = "+window.pageXOffset+"<br>";
-
strInfo +="window.pageYOffset = "+window.pageYOffset+"<br>";
-
strInfo +="window.screenLeft = "+window.screenLeft+"<br>";
-
strInfo +="window.screenTop = "+window.screenTop+"<br>";
-
strInfo +="window.screenX = "+window.screenX+"<br>";
-
strInfo +="window.screenY = "+window.screenY+"<br>";
-
-
-
strInfo +="$(document).width(), document.body.scrollWidth = "+$(document).width()+"<br>";
-
strInfo +="$(document).height(), document.body.scrollHeight = "+$(document).height()+"<br>";
-
-
rect.html(strInfo);
-
}
-
-
function on_Change()
-
{
-
showInfo();
-
}
-
-
-
function startMove()
-
{
-
setInterval(moveX, 20);
-
}
-
-
function moveX()
-
{
-
autoScroll();
-
showInfo();
-
}
-
-
function autoScroll()
-
{
-
var nY = window.pageYOffset;
-
var nMaxTop = $(document).height()-window.innerHeight;
-
-
if(nY+nSW>nMaxTop)
-
{
-
nSW =-5;
-
}
-
-
if(nY+nSW<0)
-
{
-
nSW =5;
-
}
-
-
nY+=nSW;
-
window.scrollTo(0,nY);
-
}
-
-
});
-
</script>
-
</head>
-
-
<body>
-
<div id="main">
-
</div>
-
<div id="rect">
-
</div>
-
</body>
-
</html>
'Mobile' 카테고리의 다른 글
모바일웹의 모든 것 (0) | 2011.12.28 |
---|---|
아이폰용 모바일웹 제작 팁 (0) | 2011.12.15 |
이동 태그 모음 (0) | 2011.12.15 |