代碼: 選擇全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type">
<title>浮動圖層範例</title>
</head>
<body>
<table>
<tr>
<td width="100%" height="2000px">
</td>
</tr>
</table>
<div id="iRFloating" style="position:absolute;top:100;left:1000;">
<table>
<tr>
<td valign="top">
<a href="http://www.microsoft.com/taiwan/events/teched2008/default.aspx"><img src="http://www.microsoft.com/taiwan/msdn/image/technet.gif" border="0" /></a>
</td>
</tr>
</table>
</div>
</body>
</html>
<script>
adWidth = 160;//廣告寬度
nowX = 1000;//目前位置(left)
nowY = 100;//目前位置(top)
fad_style = document.getElementById('iRFloating').style;
function fadIni()
{
innerWidth = document.body.clientWidth;
innerHeight = document.body.clientHeight;
edge = (innerWidth-1000)/2;
if( edge > adWidth )
{
posX = edge + 1000;
}
else
{
posX = innerWidth-adWidth;
}
posY = 100;
}
function fadRefresh()
{
offsetX = posX + document.body.scrollLeft - nowX;
offsetY = posY + document.body.scrollTop - nowY;
nowX += offsetX / 5;
nowY += offsetY / 5;
fad_style.left = nowX;
fad_style.top = nowY;
floatID = setTimeout('fadRefresh()', 20 );//Refresh時間
}
function fadStart()
{
fadIni();
window.onresize=fadIni;
fadRefresh();
}
fadStart();
</script>
據說出處是破解巴哈姆特右邊浮動視窗而來的