javascript写一个浮动div
要完成此效果需要三个步骤
第一步:把如下代码加入到<head>区域中
<SCRIPT LANGUAGE="JavaScript">

function setVariables() {

imgwidth=235;

imgheight=19;

if (navigator.appName == "Netscape") {

horz=".left";

vert=".top";

docStyle="document.";

styleDoc="";

innerW="window.innerWidth";

innerH="window.innerHeight";

offsetX="window.pageXOffset";

offsetY="window.pageYOffset";

}

else {

horz=".pixelLeft";

vert=".pixelTop";

docStyle="";

styleDoc=".style";

innerW="document.body.clientWidth";

innerH="document.body.clientHeight";

offsetX="document.body.scrollLeft";

offsetY="document.body.scrollTop";

}

}

function checkLocation() {

objectXY="branding";

var availableX=eval(innerW);

var availableY=eval(innerH);

var currentX=eval(offsetX);

var currentY=eval(offsetY);

x=availableX-(imgwidth+30)+currentX;

y=availableY-(imgheight+65)+currentY;

evalMove();

setTimeout("checkLocation()",10);

}

function evalMove() {

eval(docStyle + objectXY + styleDoc + horz + "=" + x);

eval(docStyle + objectXY + styleDoc + vert + "=" + y);

}

</script>
第二步:把如下代码加入到<body>区域中
<div id="branding" style="position:absolute; visibility:show; left:235px; top:50px; z-index:2">

<table width=10 ><td>

<a href="http://free.2259.com/" onmouseover="window.status='Typhoon Start';return true" onmouseout="window.status='';return true"><center>
<img src="2259.gif" border="0">
</center></a></font></td>

</table>

</div>
第三步:把“onload="setVariables(); checkLocation();"”加到<body>标记中
例如:<body onload="setVariables(); checkLocation();">
第一步:把如下代码加入到<head>区域中
<SCRIPT LANGUAGE="JavaScript"> 
function setVariables() { 
imgwidth=235; 
imgheight=19; 
if (navigator.appName == "Netscape") { 
horz=".left"; 
vert=".top"; 
docStyle="document."; 
styleDoc=""; 
innerW="window.innerWidth"; 
innerH="window.innerHeight"; 
offsetX="window.pageXOffset"; 
offsetY="window.pageYOffset"; 
} 
else { 
horz=".pixelLeft"; 
vert=".pixelTop"; 
docStyle=""; 
styleDoc=".style"; 
innerW="document.body.clientWidth"; 
innerH="document.body.clientHeight"; 
offsetX="document.body.scrollLeft"; 
offsetY="document.body.scrollTop"; 
} 
} 
function checkLocation() { 
objectXY="branding"; 
var availableX=eval(innerW); 
var availableY=eval(innerH); 
var currentX=eval(offsetX); 
var currentY=eval(offsetY); 
x=availableX-(imgwidth+30)+currentX; 
y=availableY-(imgheight+65)+currentY; 
evalMove(); 
setTimeout("checkLocation()",10); 
} 
function evalMove() { 
eval(docStyle + objectXY + styleDoc + horz + "=" + x); 
eval(docStyle + objectXY + styleDoc + vert + "=" + y); 
} 
</script> 
第二步:把如下代码加入到<body>区域中
<div id="branding" style="position:absolute; visibility:show; left:235px; top:50px; z-index:2"> 
<table width=10 ><td> 
<a href="http://free.2259.com/" onmouseover="window.status='Typhoon Start';return true" onmouseout="window.status='';return true"><center>
<img src="2259.gif" border="0">
</center></a></font></td> 
</table> 
</div> 
第三步:把“onload="setVariables(); checkLocation();"”加到<body>标记中
例如:<body onload="setVariables(); checkLocation();">
我是无聊的人,所以做无聊的事情。

浙公网安备 33010602011771号