可自行加入html的偽彈出框實作程式碼_jquery
May 16, 2016 pm 05:23 PM
html
js
複製程式碼程式碼如下:
var popupStatus = 0; jQuery 魔法載入彈出視窗!
function loadPopup(){
//僅在停用時載入彈出視窗
if(popupStatus==0){
$("#backgroundPopup").css({
"opacity ": "0.7"
});
$("#backgroundPopup").fadeIn("慢");
$("#popupContact").fadeIn("慢");
popupStatus = 1;
}
}
//使用jQuery 魔法停用彈出視窗!
function disablePopup(){
//僅在啟用時停用彈出視窗
if(popupStatus==1){
$("#backgroundPopup").fadeOut("slow");
$("#popupContact").fadeOut("慢");
popupStatus = 0;
}
}
//居中彈出視窗
function centerup(){
//居中請求資料
var browser=navigator.userAgent;
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.Height;Height; 🎜>var sleft="";
if(browser.indexOf('Chrome')!=-1){
stop=document.body.scrollTop;
sleft=document.body.scrollLeft;
}
else{
stop=document.documentElement.scrollTop;
sleft=document.documentElement.scrollLeft;
}
// windowumentElement.scrollLeft;
}
// windowWidth =sadm.body.coml. // windowHeight =document.body.scrollTop;
var popupHeight = $("#popupContact").height();
var popupWidth = $("#popupContact").width();
/ /居中
$("#popupContact").css({
"position": "absolute",
"top": windowHeight/2-popupHeight/2 stop,
"left": windowWidth/2-popupWidth/2 sleft
});
//只需要IE6強制
//背景色
$("#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程式碼(預設)
複製碼
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱門文章
倉庫:如何復興隊友
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 週前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
擊敗分裂小說需要多長時間?
3 週前
By DDD
公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?
3 週前
By 王林

熱門文章
倉庫:如何復興隊友
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 週前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
擊敗分裂小說需要多長時間?
3 週前
By DDD
公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?
3 週前
By 王林

熱門文章標籤

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)