用层模拟可移动/可隐藏的小窗口

<html>
<head>
<title>用层模拟可移动/可隐藏的小窗口丨网页特效丨接触角测定仪-益诚制衣</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META NAME="Description" CONTENT="">
<style type=‘text/css‘>
<!--
body{font-size:12px;}
a:visited{text-decoration:none;color:slategray;}
a:hover{text-decoration:underline;color:slategray;}
a:link{text-decoration:none;color:slategray;}
-->
</style>
<script language=JScript>
<!--
//可以打包为js文件;
var x0=0,y0=0,x1=0,y1=0;
var offx=6,offy=6;
var moveable=false;
var hover=‘orange‘,normal=‘#336699‘;//color;
var index=10000;//z-index;
//开始拖动;
function startDrag(obj)
{
if(event.button==1)
{
//锁定标题栏;
obj.setCapture();
//定义对象;
var win = obj.parentNode;
var sha = win.nextSibling;
//记录鼠标和层位置;
x0 = event.clientX;
y0 = event.clientY;
x1 = parseInt(win.style.left);
y1 = parseInt(win.style.top);
//记录颜色;
normal = obj.style.backgroundColor;
//改变风格;
obj.style.backgroundColor = hover;
win.style.borderColor = hover;
obj.nextSibling.style.color = hover;
sha.style.left = x1 + offx;
sha.style.top = y1 + offy;
moveable = true;
}
}
//拖动;
function drag(obj)
{
if(moveable)
{
var win = obj.parentNode;
var sha = win.nextSibling;
win.style.left = x1 + event.clientX - x0;
win.style.top = y1 + event.clientY - y0;
sha.style.left = parseInt(win.style.left) + offx;
sha.style.top = parseInt(win.style.top) + offy;
}
}
//停止拖动;
function stopDrag(obj)
{
if(moveable)
{
var win = obj.parentNode;
var sha = win.nextSibling;
var msg = obj.nextSibling;
win.style.borderColor = normal;
obj.style.backgroundColor = normal;
msg.style.color = normal;
sha.style.left = obj.parentNode.style.left;
sha.style.top = obj.parentNode.style.top;
obj.releaseCapture();
moveable = false;
}
}
//获得焦点;
function getFocus(obj)
{
if(obj.style.zIndex!=index)
{
index = index + 2;
var idx = index;
obj.style.zIndex=idx;
obj.nextSibling.style.zIndex=idx-1;
}
}
//最小化;
function min(obj)
{
var win = obj.parentNode.parentNode;
var sha = win.nextSibling;
var tit = obj.parentNode;
var msg = tit.nextSibling;
var flg = msg.style.display=="none";
if(flg)
{
win.style.height = parseInt(msg.style.height) + parseInt(tit.style.height) + 2*2;
sha.style.height = win.style.height;
msg.style.display = "block";
obj.innerHTML = "0";
}
else
{
win.style.height = parseInt(tit.style.height) + 2*2;
sha.style.height = win.style.height;
obj.innerHTML = "2";
msg.style.display = "none";
}
}
//创建一个对象;
function xWin(id,w,h,l,t,tit,msg)
{
index = index+2;
this.id = id;
this.width = w;
this.height = h;
this.left = l;
this.top = t;
this.zIndex = index;
this.title = tit;
this.message = msg;
this.obj = null;
this.bulid = bulid;
this.bulid();
}
//初始化;
function bulid()
{
var str = ""
+ "<div id=xMsg" + this.id + " "
+ "style=‘"
+ "z-index:" + this.zIndex + ";"
+ "width:" + this.width + ";"
+ "height:" + this.height + ";"
+ "left:" + this.left + ";"
+ "top:" + this.top + ";"
+ "background-color:" + normal + ";"
+ "color:" + normal + ";"
+ "font-size:8pt;"
+ "font-family:Tahoma;"
+ "position:absolute;"
+ "cursor:default;"
+ "border:2px solid " + normal + ";"
+ "‘ "
+ "onmousedown=‘getFocus(this)‘>"
+ "<div "
+ "style=‘"
+ "background-color:" + normal + ";"
+ "width:" + (this.width-2*2) + ";"
+ "height:20;"
+ "color:white;"
+ "‘ "
+ "onmousedown=‘startDrag(this)‘ "
+ "onmouseup=‘stopDrag(this)‘ "
+ "onmousemove=‘drag(this)‘ "
+ "ondblclick=‘min(this.childNodes[1])‘"
+ ">"
+ "<span style=‘width:" + (this.width-2*12-4) + ";padding-left:3px;‘>" + this.title + "</span>"
+ "<span style=‘width:12;border-width:0px;color:white;font-family:webdings;‘ onclick=‘min(this)‘>0</span>"
+ "<span style=‘width:12;border-width:0px;color:white;font-family:webdings;‘ onclick=‘ShowHide(\""+this.id+"\",null)‘>r</span>"
+ "</div>"
+ "<div style=‘"
+ "width:100%;"
+ "height:" + (this.height-20-4) + ";"
+ "background-color:white;"
+ "line-height:14px;"
+ "word-break:break-all;"
+ "padding:3px;"
+ "‘>" + this.message + "</div>"
+ "</div>"
+ "<div id=xMsg" + this.id + "bg style=‘"
+ "width:" + this.width + ";"
+ "height:" + this.height + ";"
+ "top:" + this.top + ";"
+ "left:" + this.left + ";"
+ "z-index:" + (this.zIndex-1) + ";"
+ "position:absolute;"
+ "background-color:black;"
+ "filter:alpha(opacity=40);"
+ "‘></div>";
document.body.insertAdjacentHTML("beforeEnd",str);
}
//显示隐藏窗口
function ShowHide(id,dis){
var bdisplay = (dis==null)?((document.getElementById("xMsg"+id).style.display=="")?"none":""):dis
document.getElementById("xMsg"+id).style.display = bdisplay;
document.getElementById("xMsg"+id+"bg").style.display = bdisplay;
}
//-->
</script>
<script language=‘JScript‘>
<!--
function initialize()
{
var a = new xWin("1",160,200,200,200,"窗口1","xWin <br> A Cool Pop Div Window<br>jz123.cn<br>jz123.cn");
var b = new xWin("2",240,200,100,100,"窗口2","欢迎光临『网页特效』<br><a href=http://www.dgshengding.com target=_blank>http://www.dgshengding.com</a><br>请多提建议噢<br><br>感谢您的关注!");
var c = new xWin("3",200,160,250,50,"窗口3","Copyright by <a href=‘#‘>jz123.Cn</a>!");
ShowHide("1","none");//隐藏窗口1
}
window.onload = initialize;
//-->
</script>
</head>
<base target="_blank">
<body onselectstart=‘return false‘ oncontextmenu=‘return false‘ >
<a onclick="ShowHide(‘1‘,null);return false;" href="">窗口1</a>
<a onclick="ShowHide(‘2‘,null);return false;" href="">窗口2</a>
<a onclick="ShowHide(‘3‘,null);return false;" href="">窗口3</a>
</body>
</html>
时间: 2024-10-05 05:04:41

用层模拟可移动/可隐藏的小窗口的相关文章

js制作带有遮罩弹出层实现登录小窗口

要实现的效果如下 点击“登录”按钮后,弹出登录小窗口,并且有遮罩层(这个名词还是百度知道的,以前只知道效果,却不知道名字) 在没有点击“登录”按钮之前登录小窗口不显示,点击“登录”按钮后小窗口显示,并且遮罩层笼罩整个页面,使整个页面的其他元素暂时失去行为. 遮罩层的实现:相对于body绝对定位,宽度和高度都和body相同,并且有一定的透明度,使得下面的元素能够被看到.原先的元素的z-index为0,遮罩层的z-index在弹出登录小窗口和原先元素的之间. 说的不是很清楚,还是看代码吧! <!DO

jquery实现点击按钮弹出层和点击空白处隐藏层

昨天做项目遇到一个问题,和大家分享下,jquery实现点击按钮弹出层和点击空白处隐藏层的问题 if($('.autoBtn').length){                $('.autoBtn').find('.assess').unbind().bind('click',function(event){                    //取消事件冒泡                      event.stopPropagation(); if($('.abtnBox').is

JQuery实现点击div以外的位置隐藏该div窗口

简单示例代码: <body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> $(function(){ $(document).bind("click&

windows下自动启动Redis隐藏命令行窗口

这段时间看了看关于Redis的相关内容,对于Redis在windows下的安装和常规启动我就不多说了.可以参考其他的博客http://www.cnblogs.com/edisonchou/p/3821228.html.我按照这篇博客的方法添加启动Redis的windows服务,但是在启动服务的时候,会报错:错误1053:服务没有及时响应启动或控制请求.如下图: 我查了相关资料,有的人说是因为windows8系统权限问题.我就想能不能绕过这个错误,实现自动启动Redis,而不用再命令行中启动. 一

[VBA] 如何 隐藏 Excel 主窗口

我们可以利用隐藏主窗口的方式要求使用者输入账号密码,如下图 由上图得知Excel已经在执行了,但是主要的应用程序窗口被藏起来了. 1.隐藏的方式其实很简单只要设定Application.Visible = True 属性即可 2.或是利用下列属性,将主窗口移出屏幕 Application.WindowState = xlNormal Application.Left = 10000 如何隐藏 Excel 主窗口 1.利用Workbook_Open事件,使Excel一执行后便隐藏主程序画面 Pri

模拟鼠标点击+隐藏窗口

#include<iostream> #include<conio.h> #include<windows.h> #define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0) //必要的,我是背下来的 using namespace std; int main(){ bool f=false; HWND hwnd=GetForegroundWindow();//获取最前端的窗

用层模拟可移动的小窗口

<html> <head> <title>_xWin-电表控制器</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <style type='text/css'> <!-- body{font-size:12px;} a:visited{text-decoration:none;colo

【青椒原创】2016C#模拟谷歌Google登陆Gmail&amp;Youtube小案例

之所以写这个,是因为本来想写一个Youtube刷评论的工具,把登录做出来了,后面就没继续做下去. 涉及到基本的HttpWatch的应用以及Fiddler的应用(Fd主要用来排查问题,通过对比 浏览器和vs代码 找出问题所在!以浏览器为标准). 通过HttpWatch抓包分析,我把登录Youtube一共分为三个阶段: 1. 请求 打开录入邮箱地址 页面 2. 请求 回发本邮箱地址,加载邮箱账号 头像 3. 请求 回发本邮箱地址和密码, 登录Youtube 有很多的Cookie和PostData的话

Windows 10之 隐藏“此电脑”窗口的6个额外文件夹

默认情况下,Windows 10的"此电脑"窗口会显示"视频.图片.文档.下载.音乐.桌面"六个文件夹.大部分情况下,用户使用这几个文件夹的机会并不多,有时会觉得有些"碍眼".那么,用户是否能删除(隐藏)他们呢? 要隐藏这几个文件,用户只需要在管理员权限下运行regedit程序,修改相应键值即可. (具体键值可以从附件下载) 将相应项下的"ThisPCPolicy"修改为"Hide". 桌面文件夹对应的Pr