jQuery 弹出窗口的形式一直是具体案件的中心
改成
position:fixed!important;/* FF IE7*/
position:absolute;/*IE6*/
_top: expression(eval(document.compatMode &&
document.compatMode=='CSS1Compat') ?
documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 :/*IE6*/
document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2);/*IE5 IE5.5*/
2.js方法又一次计算位置
$(function(){
$(window).scroll(function(){
//浏览器滚动栏失效;
//$(window).scrollTop(0);
var offset = $(window).offset();
var position = $(window).position();
$("#div_pop").css("top",$(window).scrollTop()+$(window).outerHeight()/3);
//滚动栏移动的高度+浏览器高度(计算外框)的三分之中的一个
$("#div_back").css("height",
$(window).scrollTop()+$(window).outerHeight()); }) //背景层的大小高度,滚动栏移动的高度+浏览器高度(计算外框)
$(function(){
$(window).scroll(function(){
//浏览器滚动栏失效;
//$(window).scrollTop(0);
})
<script>
var firefox = navigator.userAgent.indexOf('Firefox') != -1;
function MouseWheel(e) {
///对img按下鼠标滚路,阻止视窗滚动
e = e || window.event;
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
if (e.preventDefault) e.preventDefault();
else e.returnValue = false;
//其它代码
}
window.onload = function () {
var img = document.getElementById('img');
firefox ? img.addEventListener('DOMMouseScroll', MouseWheel, false) : (img.onmousewheel = MouseWheel);
}
</script><div style="height:100px"></div>
<img src="http://avatar.profile.csdn.net/C/5/A/1_px372265205.jpg" id="img" style="width:200px"/>
<div style="height:1000px"></div>
可是这种方法用onkeypress 上下键 就会失效假设想完好能够加上对上下键的监控
<!DOCTYPE html>
<html>
<head>
<title>jQuery弹出框</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
.div_back{
display:none;
position:fixed;
z-index:9998;
top:0;
left:0;
width: 100%;
height: 100%;
background-color:#666666;
opacity:0.5;
filter: alpha(opacity=50);
-moz-opacity: 0.5;
}
.div_pop{
display:none;
position:fixed;
z-index:9999;
background-color:#eafcd5;
top:30%;
left:42%;
width:200px;
height:80px;
padding:2px;
border-radius:10px;
box-shadow: 0 0 10px #666; border:2px solid #666666;
}
.div_info{
position:absolute;
padding:10px;
}
.div_info_font{
position:absolute;
width:120px;
left:80px;
top:20px;
}
.div_title{
font-size:20px;
padding:2px;
background-color:#978987;
}
.div_close{
position:absolute;
right:5px;
}
.div_img{
height:40px;
width:40px;
left:20px;
position:absolute;
}
</style>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script>
function fnClose(){
$("#div_back").hide();
$("#div_pop").hide();
}
function fnOpen(){
$("#div_back").show();
$("#div_pop").show();
}
</script>
</head>
<body>
<div id="div_back" class="div_back">
</div>
<div id="div_pop" class="div_pop" >
<div id="div_title" class="div_title">提示:
<a id="close" href="javascript:fnClose()" class="div_close">关闭</a>
</div>
<div id="div_info" class="div_info">
<img src="image/load.gif" class="div_img"/><div class="div_info_font">正在载入中...</div></div>
</div>
<p align="center">
<input type="button" value="打开" onClick="fnOpen()"/>
</p>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
</body>
</html>
版权声明:本文博客原创文章,博客,未经同意,不得转载。
jQuery 弹出窗口的形式一直是具体案件的中心的更多相关文章
- jQuery弹出窗口完整代码
jQuery弹出窗口完整代码 效果体验:http://keleyi.com/keleyi/phtml/jqtexiao/1.htm 1 <!DOCTYPE html PUBLIC "- ...
- jQuery弹出窗口浏览图片
效果预览:http://keleyi.com/keleyi/phtml/jqtexiao/3.htm HTML文件代码: <!DOCTYPE HTML> <html> < ...
- Jquery弹出窗口
今天讲了Jquery的弹出窗口的组成和用法: 先把引用文件的代码写好: // 每个弹窗的标识 var x =0; var idzt = new Array(); var Window = functi ...
- JQuery弹出窗口小插件ColorBox
本文来自: Small_陌 http://www.cnblogs.com/wggmqj/archive/2011/11/04/2236263.html 今天在博客园看到一篇<ASP.NET MV ...
- FancyBox——jQuery弹出窗口插件
最近工作项目中有用到这款插件,就查找了一下相关资料和用法,下面是一些基本的简单用法,比较容易掌握,有需要的小伙伴可以参考.:) FancyBox是一款基于jquery开发的类Lightbox插件.支持 ...
- jquery弹出窗口选择回写值
$(document).ready(function(){ $('.sel').dblclick(function(){ var nowid=$(this).attr('id'); window.op ...
- jquery-通过js编写弹出窗口
本文转载 本文主要是通过js动态控制div的高度,css控制浮动 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional// ...
- EPUB弹出窗口式脚注
网上搜到一些国学典籍的EPUB版,虽有古人的注解,但正文和注解混排在一起,当我只想迅速读正文的时候比较碍眼.于是研究了一下 EPUB3 中有关脚注(footnote)的规格定义,写了一个 Python ...
- jQuery弹出层始终垂直居中相对于屏幕或当前窗口
把弹出层的位置设为fixed,设置top:50%,然后获取当前元素的整体的高度height,用获取的高度height/2,设置margin-top:-height/2.即可把当前的弹出层始终垂直居中于 ...
随机推荐
- CSS三角形制作样式
.triangle{ display: block; height: 0; position: absolute; width: 0; border: 9px solid; border-color: ...
- hdu 4117 GRE Words (ac自动机 线段树 dp)
参考:http://blog.csdn.net/no__stop/article/details/12287843 此题利用了ac自动机fail树的性质,fail指针建立为树,表示父节点是孩子节点的后 ...
- MYSQL查询表结构
mysql查看表结构命令,如下: desc 表名;show columns from 表名;describe 表名;show create table 表名; use information_sche ...
- 测试framebuffer
static GGLContext *gr_context = 0; static GGLSurface gr_framebuffer[2]; static unsigned gr_active_fb ...
- InitInheritedComponent的执行过程
这{$R *.dfm}是一个编译指令,它只是用来告诉IDE,在编译的时候,把 *.dfm文件编到 exe文件资源里面,它本身没有编译进Exe里面. 因为TCustomForm是继承而来,所以调用TRe ...
- [置顶] android之Notification版本兼容性问题
首先先来创建一个notification提示 //概要 String tickerText = context.getResources().getText(R.string.app_name).to ...
- ORACLE 安装Oracle12遇到的问题
0.全然卸载Oracle10(Windows) 在Windows下多次安装Oracle会造成混乱.重装Oracle的话一定先要干净卸载曾经的Oracle. 一.有必要时先备份 二.卸载步骤 1.用DB ...
- Delphi -- 创建 桌面、发送到...、快速启动栏、开始菜单、程序菜单、右键菜 单
{================================================================= 功 能: 创建 桌面.发送到....快速启动栏.开始菜单.程序菜单 ...
- 让动态创建的ActiveX控件响应Windows消息
当我们通过 CWnd::CreateControl() 动态创建 ActiveX 控件时, Windows 消息并不会被发送给我 们的由 CWnd 派生得控件类.例如,即使我们为 WM_KIL ...
- 再说Java EE
说到JavaEE(曾经叫J2EE)是什么,你可能回答:JavaEE是一组规范,这么说是没错,可是自己不认为这个答案非常大.非常空么?什么又是规范?规范能组成应用么?能在JVM中跑起来么?要理解这些,先 ...