Home > Web Front-end > JS Tutorial > body text

jQuery pop-up window complete code (center, left, right)_jquery

WBOY
Release: 2016-05-16 17:49:33
Original
1159 people have browsed it

Core code:

Copy code The code is as follows:

//Get the height of the window
var windowHeight;
//Get the width of the window
var windowWidth;
//Get the width of the pop-up window
var popWidth;
//Get the height of the pop-up window
var popHeight;
function init(){
windowHeight=$(window).height();
windowWidth=$(window).width();
popHeight=$(".window").height( );
popWidth=$(".window").width();
}
//Method to close the window
function closeWindow(){
$(".title img" ).click(function(){
$(this).parent().parent().hide("slow");
});
}
//Define pop-up centered window Method
function popCenterWindow(){
init();
//Calculate the Y offset of the upper left corner of the pop-up window
var popY=(windowHeight-popHeight)/2;
var popX=(windowWidth-popWidth)/2;
//alert('www.jb51.net');
//Set the position of the window
$("#center").css( "top",popY).css("left",popX).slideToggle("slow");
closeWindow();
}
function popLeftWindow(){
init();
//Calculate the offset of Y in the upper left corner of the pop-up window
var popY=windowHeight-popHeight;
//var popX=-(windowWidth-popWidth);
//alert(popY);
//Set the position of the window
$("#left").css("top",popY-50).css("left",50).slideToggle("slow");
closeWindow();
}
function popRightWindow(){
init();
//Calculate the Y offset of the upper left corner of the pop-up window
var popY=windowHeight-popHeight;
var popX=windowWidth-popWidth;
//alert(www.cnblogs.com/jihua);
//Set the position of the window
$("#right").css(" top",popY-50).css("left",popX-50).slideToggle("slow");
closeWindow();
}

Full code:

[Ctrl A select all Note:
If you need to introduce external Js, you need to refresh to execute ]Author cnblogs jihua
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!