일반적으로 사용 :
JS 브라우저 창 크기를 얻습니다
다음과 같이 코드 코드를 복사하십시오.
// 창의 너비를 얻습니다
if (window.innerWidth)
winwidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth))
winwidth = document.body.clientWidth;
// 창 높이를 얻습니다
if (window.innerheight)
Winheight = Window.innerHeight;
else if ((document.body) && (documen.body.clientHeight))
winheight = document.body.clitingHeight;
// 문서 내부 내부 감지를 통해 창 크기가 얻어집니다.
if (docut
{{
winheight = document.documentedlement.clientHeight;
winwidth = document.documentElement.clientWidth;
}
상세한:
다양한 브라우저를 얻기 위해 창 크기를 볼 수 있습니다.
<cript>
함수 getInfo ()
{{
var s = "";
S = "웹 페이지는 넓은 영역을 가시 할 수 있습니다 :"document.body.clientWidth;
S = "웹 페이지 가시 영역 높이 :"Document.body.ClientHeight;
S = "웹 페이지 가시 영역 너비 :"Document.body.offsetWidth "(가장자리 너비 및 롤링 바 포함)";
S = "웹 페이지 가시 영역 높이 :"document.body.offsetheight "(가장자리 너비 포함)";
S = "웹 페이지 텍스트 전체 텍스트 너비 :"document.body.scrollwidth;
S = "웹 페이지 텍스트 전체 텍스트 높이 :"document.body.scrollheight;
웹 페이지에 의해 롤링되는 S = "FF) :"Document.body.scrolltop;
"웹 페이지의 S ="IE)는 롤아웃 (예 : document.documentElement.scroltop;
S = "웹 페이지는 왼쪽에 롤업됩니다."Document.body.scrollleft;
S = "웹 페이지 텍스트 파트 :"window.screentop;
S = "웹 페이지 텍스트 부분 왼쪽 :"Window.ScreenLeft;
S = "화면 해상도 :"Window.screen.height;
S = "화면 해상도 너비 :"Window.screen.width;
S = "화면 사용 가능한 작업 영역 높이 :"Window.Screen.availHeight;
S = "화면 사용 가능한 작업 영역 너비 :"Window.Screen.availWidth;
S = "화면 설정은"window.screen.colordepth "입니다.
S = "화면 설정"Window.Screen.DeviceXDPI "Pixel/Incon";
// 경고;
}
getInfo ();
</스크립트>
내 지역 테스트에서 :
IE, Firefox, Opera에서 사용할 수 있습니다
document.body.clientWidth
document.body.clitingHeight
매우 간단하고 편리하게 얻을 수 있습니다.
그리고 회사 프로젝트에서 :
오페라는 여전히 사용됩니다
document.body.clientWidth
document.body.clitingHeight
그러나 IE와 Firefox가 사용됩니다
document.documentElement.clientWidth
Document.DocumentELement.ClientHeight
그것은 W3C의 표준으로 판명되었습니다.
<!
이 라인을 페이지에 추가하면 IE입니다.
document.body.clientWidth ==> 바디 객체 너비
document.body.clitingheight ==> 바디 객체 높이
document.documentElement.clientWidth ==> 가시 영역 너비
document.documentElement.clientHeight ==> 가시 영역 높이
Firefox에서 :
document.body.clientWidth ==> 바디 객체 너비
document.body.clitingheight ==> 바디 객체 높이
document.documentElement.clientWidth ==> 가시 영역 너비
document.documentElement.clientHeight ==> 가시 영역 높이
오페라 :
document.body.clientWidth ==> 가시 영역 너비
document.body.clitingHeight ==> 가시 영역 높이
document.documentElement.clientWidth ==> 페이지 객체 너비 (즉, 바디 객체의 너비 + 마진 너비)
document.documentElement.clientHeight == >> 페이지 객체 높이 (즉, 신체 객체의 높이 + 마진 높이)
W3C의 표준 정의가 없다면
즉, :
document.documentElement.clientWidth ==> 0
document.documentElement.clientHeight ==> 0
Firefox는 다음과 같습니다.
document.documentElement.clientWidth ==> 페이지 객체 너비 (즉, 바디 객체의 너비 + 여백 너비) document.documenetElement.clientHeight ==> 페이지 얼굴 개체 높이 (즉, 신체 객체의 높이 + 마진 높이)
오페라는 :
document.documentElement.clientWidth ==> 페이지 객체 너비 (즉, 바디 객체의 너비 + 여백 너비) document.documenetElement.clientHeight ==> 페이지 얼굴 개체 높이 (즉, 신체 객체의 높이 + 마진 높이)