简单图层效果
来源:互联网 发布:linux socket编程教程 编辑:程序博客网 时间:2024/04/30 09:58
<!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>
<style type="text/css">
body {
margin:0;
padding:0;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>弹层效果</title>
<script language="javascript">
function msgbox(){ //背景图层的生成块
var msg = document.createElement("div");
msg.id = "layer";
//msg.innerHTML = "<a href='#'> oh my gold is very good!</a>";
with (msg.style){
width = "100%";
height = document.documentElement.clientHeight + "px";
background = "#E9E9E9";
position = "absolute";
left = "0";
top = "0";
filter = 'Alpha(opacity=70)';//设置透明度
opacity = '0.7';//不透明度
}
document.body.appendChild(msg);
//以下是图片图层的运用
var message = document.createElement("div");
message.id = "messgebox";
message.innerHTML = "<img src='baidu_sylogo1.gif' onclick='Hlose()'/>";//不能用小写的close()否则将不识别
// onmousedown='MouseDown(this)' onmousemove='MouseMove()' onmouseup='MouseUp()'
with (message.style){
position = "absolute";
left = "37%";
top = "30%";
width = "500px";
height = "500px";
}
document.body.appendChild(message);//添加图层 div;
}
function Hlose(){//清楚添加的两个div
document.body.removeChild(document.getElementById("layer"));
document.body.removeChild(document.getElementById("messgebox"));
}
//以下代码是图层的移动 方法
var Obj;
function MouseDown(obj){
Obj = obj;
Obj.setCapture();
Obj.l = event.x - Obj.style.pixelLeft;
Obj.t = event.y - Obj.style.pixelTop;
}
function MouseMove() {
if (Obj != null) {
Obj.style.left = event.x - Obj.l;
Obj.style.top = event.y - Obj.t;
}
}
function MouseUp() {
if (Obj != null) {
Obj.releaseCapture();
Obj = null;
}
}
//禁止键盘按F5刷新
document.onkeydown = function () {
if (event.keyCode == 116) {
event.keyCode = 0;
event.returnValue = false;
}
}
</script>
</head>
<body>
<div style="text-align:center;margin-top:20%;">
<input type="button" value="显示" onclick="msgbox();" />
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
body {
margin:0;
padding:0;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>弹层效果</title>
<script language="javascript">
function msgbox(){ //背景图层的生成块
var msg = document.createElement("div");
msg.id = "layer";
//msg.innerHTML = "<a href='#'> oh my gold is very good!</a>";
with (msg.style){
width = "100%";
height = document.documentElement.clientHeight + "px";
background = "#E9E9E9";
position = "absolute";
left = "0";
top = "0";
filter = 'Alpha(opacity=70)';//设置透明度
opacity = '0.7';//不透明度
}
document.body.appendChild(msg);
//以下是图片图层的运用
var message = document.createElement("div");
message.id = "messgebox";
message.innerHTML = "<img src='baidu_sylogo1.gif' onclick='Hlose()'/>";//不能用小写的close()否则将不识别
// onmousedown='MouseDown(this)' onmousemove='MouseMove()' onmouseup='MouseUp()'
with (message.style){
position = "absolute";
left = "37%";
top = "30%";
width = "500px";
height = "500px";
}
document.body.appendChild(message);//添加图层 div;
}
function Hlose(){//清楚添加的两个div
document.body.removeChild(document.getElementById("layer"));
document.body.removeChild(document.getElementById("messgebox"));
}
//以下代码是图层的移动 方法
var Obj;
function MouseDown(obj){
Obj = obj;
Obj.setCapture();
Obj.l = event.x - Obj.style.pixelLeft;
Obj.t = event.y - Obj.style.pixelTop;
}
function MouseMove() {
if (Obj != null) {
Obj.style.left = event.x - Obj.l;
Obj.style.top = event.y - Obj.t;
}
}
function MouseUp() {
if (Obj != null) {
Obj.releaseCapture();
Obj = null;
}
}
//禁止键盘按F5刷新
document.onkeydown = function () {
if (event.keyCode == 116) {
event.keyCode = 0;
event.returnValue = false;
}
}
</script>
</head>
<body>
<div style="text-align:center;margin-top:20%;">
<input type="button" value="显示" onclick="msgbox();" />
</div>
</body>
</html>
- 简单图层效果
- 一个简单的层打开效果
- 最简单的弹出层效果
- 图层动态伸缩效果
- 图层动态伸缩效果
- PS之图层效果
- 鼠标划过图层变色效果
- 定时消失的图层效果
- JS 实现图层模式覆盖效果
- ImageView阴影和图层效果
- ImageView阴影和图层效果
- css3-animation图层放大效果
- ImageView阴影和图层效果
- ImageView阴影和图层效果
- 一个层下拉效果
- 拖动层效果
- DIV拖动层效果
- 弹出层效果
- 怎样获得虚函数指针
- 韩顺平网页设计第四十一讲
- 继承的理解
- sql 几个细节
- ios 之图片的拉伸的2种方法
- 简单图层效果
- 实现一个以空白符分隔字符串的split函数
- Xshell使用技巧
- w25q16 driver
- 并行编程之Fork/Join框架
- IIS安装方法
- Android系统权限和root权限
- CONFIG_VMSPLIT_2G
- 采用beautifulsoup库 解析html页面