묻고답하기
오른쪽 따라다니는 메뉴
2008.02.01 21:56
일반스크립트에서는 정상인데
메인레이아웃에 넣으면 제대로 동작을 안합니다.
방법을 좀 알려주세요
1. 일반스크립트는 정상으로 됩니다.
<script language="javascript">
<!--
var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isNS = navigator.appName == "Netscape";
function getRef(id) {
if (isDOM) return document.getElementById(id);
if (isIE4) return document.all[id];
if (isNS4) return document.layers[id];
}
var scrollerHeight = 88;
var puaseBetweenImages = 3000;
var imageIdx = 0;
function startVScroll() {
}
function moveRightEdge() {
var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
if (isDOM) {
yMenuFrom = parseInt (divMenu.style.top, 10);
yMenuTo = (isNS ? window.pageYOffset : document.body.scrollTop) + 115; // 위쪽 위치
}
timeoutNextCheck = 500;
if (yMenuFrom != yMenuTo) {
yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
if (yMenuTo < yMenuFrom)
yOffset = -yOffset;
if (isNS4)
divMenu.top += yOffset;
else if (isDOM)
divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
timeoutNextCheck = 10;
}
setTimeout ('moveRightEdge()', timeoutNextCheck);
}
//-->
</script>
<div id="divMenu" style="top:16px; left:394px; visibility: visible; width: 147px; position:absolute; height: 144px;">
<table width="104" border="0" cellspacing="5" cellpadding="0">
<tr>
<td>
<img src="http://yourdentist.co.kr/zbxe/images/banner/naver.gif" border="0"></td>
</tr>
<tr>
<td><a target="_blank" href="http://blog.yahoo.co.kr/whiteursmile">
<img src="http://yourdentist.co.kr/zbxe/images/banner/yahoo.gif" border="0"></a></td>
</tr>
<tr>
<td><a target="_blank" href="http://blog.daum.net/whiteursmile">
<img src="http://yourdentist.co.kr/zbxe/images/banner/daum.gif" border="0"></a></td>
</tr>
</table>
<p> </div>
<script language="javascript">
<!--
if (isDOM) {
var divMenu = getRef('divMenu');
divMenu.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) + 0;
divMenu.style.visibility = "visible";
moveRightEdge();
}
//-->
</script>
<img src="http://osjdent.co.kr/img/info/01_02_img.jpg"><p>
<img src="http://osjdent.co.kr/img/info/01_02_img.jpg"></p>
<p><img src="http://osjdent.co.kr/img/info/01_02_img.jpg">
2.메인 레이아웃에 소스넣으면 제대로 안됨
(1)
slide.js 에 아래의 소스저장
var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isNS = navigator.appName == "Netscape";
function getRef(id) {
if (isDOM) return document.getElementById(id);
if (isIE4) return document.all[id];
if (isNS4) return document.layers[id];
}
var scrollerHeight = 88;
var puaseBetweenImages = 3000;
var imageIdx = 0;
function startVScroll() {
}
function moveRightEdge() {
var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
if (isDOM) {
yMenuFrom = parseInt (divMenu.style.top, 10);
yMenuTo = (isNS ? window.pageYOffset : document.body.scrollTop) + 115; // 위쪽 위치
}
timeoutNextCheck = 500;
if (yMenuFrom != yMenuTo) {
yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
if (yMenuTo < yMenuFrom)
yOffset = -yOffset;
if (isNS4)
divMenu.top += yOffset;
else if (isDOM)
divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
timeoutNextCheck = 10;
}
setTimeout ('moveRightEdge()', timeoutNextCheck);
}
(2) main 레이아웃에 소스넣음
layout에 import시킴
<!--%import("js/slide.js")-->
<script language="javascript">
if (isDOM) {
var divMenu = getRef('divMenu');
divMenu.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) + 0;
divMenu.style.visibility = "visible";
moveRightEdge();
}
</script>
<img src="http://osjdent.co.kr/img/info/01_02_img.jpg"><p>
<img src="http://osjdent.co.kr/img/info/01_02_img.jpg"></p>
<p><img src="http://osjdent.co.kr/img/info/01_02_img.jpg">
굉장히 편리하게 잘 쓸 수 있게 돼 있더군요.