>  기사  >  웹 프론트엔드  >  yourself_jquery로 html 의사 팝업 상자 구현 코드를 추가할 수 있습니다.

yourself_jquery로 html 의사 팝업 상자 구현 코드를 추가할 수 있습니다.

WBOY
WBOY원래의
2016-05-16 17:23:121252검색

js

复代码 代码如下:

var popupStatus = 0;
//jQuery 매직으로 팝업을 로드 중입니다!
function loadPopup(){
//비활성화된 경우에만 팝업을 로드합니다.
if(popupStatus==0){
$("#BackgroundPopup").css({
"opacity ": "0.7"
});
$("#BackgroundPopup").fadeIn("느림");
$("#popupContact").fadeIn("느림");
popupStatus = 1;
}
}
//jQuery 매직으로 팝업을 비활성화합니다!
function 비활성화Popup(){
//활성화된 경우에만 팝업을 비활성화합니다.
if(popupStatus==1){
$("#BackgroundPopup").fadeOut("slow");
$("#popupContact").fadeOut("느림");
popupStatus = 0;
}
}
//센터링 팝업
function centerPopup(){
//센터링을 위한 데이터 요청
var browser=navigator.userAgent;
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var stop="";
var sleft="";
if(browser.indexOf('Chrome')!=-1){
stop=document.body.scrollTop;
sleft=document.body.scrollLeft;
}
else{
stop=document.documentElement.scrollTop;
sleft=document.documentElement.scrollLeft;
}
// windowWidth =document.body.scrollLeft;
// windowHeight =document.body.scrollTop;
var popupHeight = $("#popupContact").height();
var popupWidth = $("#popupContact").width();
//센터링
$("#popupContact").css({
"position": "absolute",
"top": windowHeight/2-popupHeight/2 stop,
"왼쪽": windowWidth/2-popupWidth/2 sleft
});
//IE6에만 강제가 필요합니다
//背景color
$("#BackgroundPopup").css({
"height": windowHeight
});
}
//调用弹框事件
function bb(str){
$("#download").show();
centerPopup();
loadPopup();
//팝업 종료
//x 이벤트를 클릭하세요!
$("#popupContactClose").click(function(){
disablePopup();
});
//이벤트 클릭!,点击背景事件
$("#BackgroundPopup").click(function(){
disablePopup();
});
//탈출 누르기 이벤트!
$(document).keypress(function(e){
if(e.keyCode==27 && popupStatus==1){
disablePopup();
}
});
}

html代码(默认隐藏)
复system代码 代码如下:



성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
이전 기사:Node.js 함수는 html에서 className의 내용을 가져오고 tag_javascript 기술을 제거합니다.다음 기사:Node.js 함수는 html에서 className의 내용을 가져오고 tag_javascript 기술을 제거합니다.

관련 기사

더보기