JavaScript에서는 eoterwidth 및 eoterheight를 사용하여 브라우저의 크기를 얻을 수 있습니다. 내부와 내부를 사용하여 창 크기를 얻으십시오 (브라우저 테두리 부분 제외). IE6 및 이전 버전의 경우 표준 모드인지 혼합 모드인지를 구별해야합니다. 표준 모드는 document.documentElement.clientWidth, document.documentElement.clientHeight를 사용합니다. Prandiscous Mode는 Document.body의 ClientWidth, ClientHeight를 사용합니다.
코드 사본은 다음과 같습니다.
(기능 () {
var pagewidth = window.innerWidth;
var pageheight = window.innerheight;
var broswerwidth = Window.outerWidth;
var broswerheight = Window.outerHeight;
ALERT (pageWidth + "" + pageHeight);
경고 (broswerwidth + "" + broswerheight);
if (typeof pagewidth! = "number") {
if (document.comPatMode == "CSS1compat") {// 표준 모드
pagewidth = document.documentElement.clientWidth;
pageheight = document.documentElement.clientHeight;
} 또 다른 {
pagewidth = document.body.clientWidth;
pageheight = document.body.clientHeight;
}
}
}) ();
창의 위치를 가져옵니다 : 즉, 크롬, 사파리, 스크린 레프트, 스크린 탑을 사용하여 화면의 왼쪽과 상단에서 창의 위치를 얻으십시오. Firefox는이 속성을 지원하지 않습니다. Firefox는 ScreenXP 및 Screeny를 사용하여 동일한 효과를 달성합니다.
코드 사본은 다음과 같습니다.
(함수 btnfun () {
var leftpos = (typeof window.screenleft == "number")? Window.screenLeft :
Window.screenx;
var toppos = (typeof window.screentop == "number")? Window.Screentop :
Window.screeny;
경고 (왼쪽 + "" + Toppos);
//alert(window.screenleft+ ""+Window.screentop);
}) ();