第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > jQuery弹出窗口完整代码(居中 居左 居右)【jquery】

jQuery弹出窗口完整代码(居中 居左 居右)【jquery】

时间:2023-06-04 12:33:12

相关推荐

jQuery弹出窗口完整代码(居中 居左 居右)【jquery】

web前端|js教程

弹出窗口

web前端-js教程

核心代码:

优秀的网站源码,ubuntu更改磁盘名字,一键安装tomcat绑定,scrapy微信爬虫,php怎么去除字符串,seo选品工具lzw

//获取窗口的高度

var windowHeight;

//获取窗口的宽度

var windowWidth;

//获取弹窗的宽度

var popWidth;

//获取弹窗高度

var popHeight;

function init(){

windowHeight=$(window).height();

windowWidth=$(window).width();

popHeight=$(".window").height();

popWidth=$(".window").width();

}

//关闭窗口的方法

function closeWindow(){

$(".title img").click(function(){

$(this).parent().parent().hide("slow");

});

}

//定义弹出居中窗口的方法

function popCenterWindow(){

init();

//计算弹出窗口的左上角Y的偏移量

var popY=(windowHeight-popHeight)/2;

var popX=(windowWidth-popWidth)/2;

//alert(\);

//设定窗口的位置

$("#center").css("top",popY).css("left",popX).slideToggle("slow");

closeWindow();

}

function popLeftWindow(){

init();

//计算弹出窗口的左上角Y的偏移量

var popY=windowHeight-popHeight;

//var popX=-(windowWidth-popWidth);

//alert(popY);

//设定窗口的位置

$("#left").css("top",popY-50).css("left",50).slideToggle("slow");

closeWindow();

}

function popRightWindow(){

init();

//计算弹出窗口的左上角Y的偏移量

var popY=windowHeight-popHeight;

var popX=windowWidth-popWidth;

//alert(/jihua);

//设定窗口的位置

$("#right").css("top",popY-50).css("left",popX-50).slideToggle("slow");

closeWindow();

}

完整代码:

工单管理系统源码 web,ubuntu循环创建目录,什么系统适合爬虫,怎么确定php,精通seo教程lzw

jQuery弹出窗口 – 脚本之家

淘宝客返利分销源码,ubuntu更改串口名称,虚拟目录访问tomcat,爬虫思路图片,php代码执行终端命令,itmc seolzw

.window{ width:250px; background-color:#d0def0; position:absolute; padding:2px; margin:5px; display:none; } .content{ height:150px; background-color:#FFF; font-size:14px; overflow:auto; } .title{ padding:2px; color:#0CF; font-size:14px; } .title img{ float:right; }

$(document).ready(function () { $(“#btn_center”).click(function () { popCenterWindow(); });

$(“#btn_right”).click(function () { popRightWindow(); }); $(“#btn_left”).click(function () { popLeftWindow(); });

});

脚本之家-居中窗口

脚本之家-居左窗口

脚本之家-居右窗口

//获取窗口的高度 var windowHeight; //获取窗口的宽度 var windowWidth; //获取弹窗的宽度 var popWidth; //获取弹窗高度 var popHeight; function init(){ windowHeight=$(window).height(); windowWidth=$(window).width(); popHeight=$(“.window”).height(); popWidth=$(“.window”).width(); } //关闭窗口的方法 function closeWindow(){ $(“.title img”).click(function(){ $(this).parent().parent().hide(“slow”); }); } //定义弹出居中窗口的方法 function popCenterWindow(){ init(); //计算弹出窗口的左上角Y的偏移量 var popY=(windowHeight-popHeight)/2; var popX=(windowWidth-popWidth)/2; //alert(‘’); //设定窗口的位置 $(“#center”).css(“top”,popY).css(“left”,popX).slideToggle(“slow”); closeWindow(); } function popLeftWindow(){ init(); //计算弹出窗口的左上角Y的偏移量 var popY=windowHeight-popHeight; //var popX=-(windowWidth-popWidth); //alert(popY); //设定窗口的位置 $(“#left”).css(“top”,popY-50).css(“left”,50).slideToggle(“slow”); closeWindow(); } function popRightWindow(){ init(); //计算弹出窗口的左上角Y的偏移量 var popY=windowHeight-popHeight; var popX=windowWidth-popWidth; //alert(/jihua); //设定窗口的位置 $(“#right”).css(“top”,popY-50).css(“left”,popX-50).slideToggle(“slow”); closeWindow(); }

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]作者 cnblogs jihua

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。