教程集 www.jiaochengji.com
教程集 >  脚本编程  >  javascript  >  正文 Js 悬浮窗口(可固定位置)代码

Js 悬浮窗口(可固定位置)代码

发布时间:2015-03-12   编辑:jiaochengji.com
分享一例js实现的可固定位置的悬浮窗口代码,有需要的朋友可以参考学习下。

本节内容:
Js 悬浮窗口

说明:
固定位置的Js悬浮窗口,代码有详细的注释。

例子:
 

复制代码 代码示例:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Fixed固定位置的悬浮 - www.jiaochengji.com</title>
<style>
* { font-size:12px; font-family:Verdana,宋体; }
html, body { margin:0px; padding:0px; overflow:hidden; }
.b { margin:0px; padding:0px; overflow:auto; }
.line0 { line-height:20px; background-color:lightyellow; padding:0px 15px; }
.line1 { line-height:18px; background-color:lightblue; padding:0px 10px; }
.w { position:absolute; right:10px; bottom:10px; width:160px; height:240px; overflow:hidden; border:2px groove #281; cursor:default; -moz-user-select:none; }
.t { line-height:20px; height:20px; width:160px; overflow:hidden; background-color:#27C; color:white; font-weight:bold; border-bottom:1px outset blue; text-align:center; }
.winBody { height:218px; width:160px; overflow-x:hidden; overflow-y:auto; border-top:1px inset blue; padding:10px; text-indent:10px; background-color:white; }
</style>
</head>
<body>
<div class="w">
<div class="t">Demo Win - Fixed</div>
<div class="winBody">Hello world</div>
</div>
</body>
<script>
//测试用,随机生成一些内容,便于测试效果。
for(var i=0; i<400; i++)document.write("<div class=\"line"+(i%2)+"\">"+(new Array(20)).join((Math.random()*1000000).toString(36)+" ")+"<\/div>");
//代码如下:
new function(w,b,c,d,o){ // www.jiaochengji.com
 d=document;b=d.body;o=b.childNodes;c="className";
 b.appendChild(w=d.createElement("div"))[c]= "b";
 for(var i=0; i<o.length-1; i++)if(o[i][c]!="w")w.appendChild(o[i]),i--;
 (window.onresize = function(){
  w.style.width = d.documentElement.clientWidth + "px";
  w.style.height = d.documentElement.clientHeight + "px";
 })();
}
</script>
</html>

您可能感兴趣的文章:
JS右下角悬浮广告代码的简单示例
Js 悬浮窗口(可固定位置)代码
js 固定悬浮效果的代码分享
JS悬浮移动窗口(悬浮广告)的特效代码
javascript 漂亮的网页右下角固定悬浮窗口
javascript 仿淘宝网悬停在页面固定位置的菜单窗口
怎么实现ASP.NET关闭当前窗口同时打开新窗口
深入解析JavaScript操纵窗口的方法
jQuery 位置插件
JQUERY 实现窗口滚动搜索框停靠效果(类似滚动停靠)

[关闭]
~ ~