웹페이지 확대/축소 스크립트
<script language=javascript>
//////////////////////////////////////////////////
var nowZoom = 100; // 현재비율
var maxZoom = 200; // 최대비율(500으로하면 5배 커진다)
var minZoom = 100; // 최소비율
// +, - 키를 입력하면 화면 확대, 축소를 한다.
document.onkeypress = getKey;function getKey(keyStroke) {
isNetscape = (document.layers);
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
which = String.fromCharCode(eventChooser).toLowerCase();
which2 = eventChooser;var el = event.srcElement;
if ((el.tagName != "INPUT") && (el.tagName != "TEXTAREA")) {
if (which == "+") {
zoomIn();
} else if (which == "-") {
zoomOut();
}
}
}
//화면 키운다.
function zoomIn() {
if (nowZoom < maxZoom) {
nowZoom += 25; //25%씩 커진다.
} else {
return;
}document.body.style.zoom = nowZoom + "%";
}//화면 줄인다.
function zoomOut() {
if (nowZoom > minZoom) {
nowZoom -= 25; //25%씩 작아진다.
} else {
return;
}document.body.style.zoom = nowZoom + "%";
}
</script>
<a href="#" onclick="zoomIn(); return false;" onfocus="blur()">확대</a>
<a href="#" onclick="zoomOut(); return false;" onfocus="blur()">축소</a>
키보드의 + / - 버튼으로도 제어 가능