台灣最大程式設計社群網站
線上人數
1522
 
會員總數:246229
討論主題:189787
歡迎您免費加入會員
討論區列表 >> 專欄文章 >> 調整瀏覽器視窗的同時讓Div跟著移動位置(Patw)
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
調整瀏覽器視窗的同時讓Div跟著移動位置(Patw)
價值 : 0 QP  點閱數:2177 回應數:0
樓主

站務人員 站長
門外漢
0 1580
542 9
發送站內信

捐贈 VP 給 站務人員
-------------------------------------------------
<script language="JavaScript">
/*
Made By Eddie Traversa.
*/

float_init = 1;
function DHTML_Init(Object) {
if (navigator.userAgent.match(/Mozilla\/5\../) && float_init) {
SetObjectOffsetTop(Object, undefined);
} }
function All (ID) {
if (document.all) { return document.all[ID]; }
else if (document.documentElement){
return document.getElementById (ID); }
else if (document.layers) { return document.layers[ID]; }}
function GetWindowOffsetTop() {
if (window.innerHeight) { return window.pageYOffset; }
else if (document.body) { return document.body.scrollTop; }}
function GetWindowHeight() {
if (window.innerHeight) { return window.innerHeight; }
else if (document.body) { return document.body.clientHeight; }}
function GetObjectHeight(Object) {
DHTML_Init(Object);
if (document.all || document.documentElement) {
Clip = Object.style.clip;
if (! Clip) { return Object.offsetHeight; }
else { return GetClipElement (Clip, 'Bottom'); }}
else if (document.layers) { return Object.clip.height; }}
function GetClipElement (Clip, Element) {
Clip = Clip.substr(Clip.indexOf('(') + 1);
Clip = Clip.substr(0, Clip.length - 1);
Clippers = Clip.split (" ");
for (i = 0; i < Clippers.length; i++) {
if (Clippers[i] != 'auto')
{ Clippers[i] = Clippers[i].replace (/D/g, ""); }}
ClipTop = Number(Clippers[0]);
ClipRight = Number(Clippers[1]);
ClipBottom = Number(Clippers[2]);
ClipLeft = Number(Clippers[3]);
if (Element == 'Top') { return ClipTop; }
else if (Element == 'Right') { return ClipRight; }
else if (Element == 'Bottom') { return ClipBottom; }
else if (Element == 'Left') { return ClipLeft; }
else { return undefined; }}
function GetObjectOffsetTop(Object) {
DHTML_Init(Object);
if (Object.offsetTop) { return Object.offsetTop; }
else if (document.layers) { return Object.top; }}
function SetObjectOffsetTop(Object, Offset) {
if (Object.style) { Object.style.top = Offset; }
else if (Object.top) { Object.top = Offset; }}
CenterMenu = 1;
MenuBorder = 100;
TimeCheck = 250;
TimeUpdate = 15;
DivUpdate = 15;
Minimum = 50;
AddHeight = -4;
function ScrollMenu() {
Menu = All('persistMenu');
WinTop = GetWindowOffsetTop();
WinHeight = GetWindowHeight() + AddHeight;
MenuTop = GetObjectOffsetTop(Menu);
MenuHeight = GetObjectHeight (Menu);
MenuNew = (CenterMenu) ? Math.round (WinTop + (WinHeight - MenuHeight) / 3) : WinTop + MenuBorder;
if (MenuNew < Minimum)
{ MenuNew = Minimum; }
if (MenuTop != MenuNew) {
if ( (MenuTop + MenuHeight) < WinTop || MenuTop > (WinTop + WinHeight) ) {
SetObjectOffsetTop (Menu, (MenuTop < MenuNew) ? (WinTop - MenuHeight) : (WinTop + WinHeight));
} else {
Add = (MenuTop < MenuNew) ? 1 : -1;
SetObjectOffsetTop (Menu, MenuTop + Math.round((MenuNew - MenuTop) / DivUpdate) + Add);
}
}
window.setTimeout('ScrollMenu()', (GetObjectOffsetTop(Menu) == MenuNew) ? TimeCheck : TimeUpdate);
}

</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" onLoad="ScrollMenu()">
<!-- PersistentLayer-->
<DIV id="persistMenu" style="position: absolute; height:200px; width:200px; left:30px; top:1px;z-index: 100">
我會跟著動哦^__________^</DIV>
<!--End PersistentLayer-->
</body>
</html>

本篇文章發表於2001-06-20 00:00
目前尚無任何回覆
   

回覆
如要回應,請先登入.