Javascript 后台未显示自定义的伪弹出窗口
我对伪弹出窗口的背景有问题。我使用jQuery(1.7)并在我的网站中创建弹出窗口。基本上,我有两个预格式化的div(一个半透明以隐藏页面的其余部分,另一个-以图像为背景-包含实际的弹出窗口,CSS已经加载到页面中),它们没有显示,并且在需要它们显示弹出窗口时显示,第二个div还有额外的填充(要有不同的弹出窗口) 我的问题是,弹出窗口的背景没有加载,并且我最终只得到半透明的背景和弹出窗口的内容。但是,如果在控制台中禁用/启用CSS背景属性,背景会重新显示,就像它最初应该显示的那样 这个问题最近才出现,不是在对实际的弹出功能进行任何修改之后,所以我真的不知道它可能来自哪里。这不可能是背景图像尚未加载的问题,因为加载页面时它已经存在了 相关代码: HTML: Javascript:Javascript 后台未显示自定义的伪弹出窗口,javascript,jquery,css,Javascript,Jquery,Css,我对伪弹出窗口的背景有问题。我使用jQuery(1.7)并在我的网站中创建弹出窗口。基本上,我有两个预格式化的div(一个半透明以隐藏页面的其余部分,另一个-以图像为背景-包含实际的弹出窗口,CSS已经加载到页面中),它们没有显示,并且在需要它们显示弹出窗口时显示,第二个div还有额外的填充(要有不同的弹出窗口) 我的问题是,弹出窗口的背景没有加载,并且我最终只得到半透明的背景和弹出窗口的内容。但是,如果在控制台中禁用/启用CSS背景属性,背景会重新显示,就像它最初应该显示的那样 这个问题最近才
//When initializing the page
$(document).ready(function(){
//[...]
popup = new Popup();
popup.initialize();
}
function Popup(){
var popupStatus = 0;
function togglePopup(){
if(popupStatus == 0){
centerPopup();
loadPopup();
}
else
disablePopup();
}
function loadPopup(){
if(popupStatus == 0){
$('#backgroundPopup').css({
"opacity": "0.7"
});
$('#backgroundPopup').fadeIn("fast");
$('#popup_container').fadeIn("fast");
$('body').scrollTop(0);
$('body').css('overflow', 'hidden');
popupStatus = 1;
}
}
this.disablePopup = function(){
if(popupStatus == 1){
$('#backgroundPopup').fadeOut("fast");
$('#popup_container').fadeOut("fast");
$('#popup_container').empty();
$('body').css('overflow', 'auto');
popupStatus = 0;
}
}
function centerPopup(){
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $('#popup_container').height();
var popupWidth = $('#popup_container').width();
$('#popup_container').css({
"position": "absolute",
"top": windowHeight/2 - popupHeight/2,
"left": windowWidth/2 - popupWidth/2
});
$('#backgroundPopup').css({
"height": windowHeight
});
}
this.initialize = function(){
$('#backgroundPopup').click(function(){
popup.disablePopup();
});
$(document).keypress(function(e){
if(e.keyCode==27)
popup.disablePopup();
});
}
this.contacts = function(){
//Fill the popup container...
centerPopup();
loadPopup();
popupDiv.fadeIn('fast');
}
可能是什么
提前感谢您的帮助
编辑:可以找到网站(早期版本)
更新:在某些时候,我认为这是由于loadPopup()函数添加的不透明属性造成的,所以我删除了这部分代码;但是错误仍然出现(虽然可能不太频繁,但很难确定,因为它最初是暂时的).我知道这不是作为答案的查询方式,但我无法在评论中添加图像,所以我在这里提问。我刚刚解决了你的问题,我得到的是你看不到下面的屏幕截图。它的输出是否正确。如果能真正看到你的代码或有问题的页面,那就太好了。很难说出问题所在问题可能是看不到代码。在jsfiddle.net中运行代码会非常有用。而且,这是在每个浏览器中都会出现,还是只是在特定的浏览器中出现?谢谢你的回答。似乎只有在chrome(最新版本)上才会出现。我已经添加了一个链接到正在建设的网站。我们应该点击什么来触发弹出窗口/模式?另外,在这里发布您代码的相关摘录,否则一旦您的网站修复,这个问题就没有任何意义了(因为它只会链接到一个固定页面)。我发布了代码摘录。要触发弹出窗口,您应该登录(抱歉,现在只能通过Facebook完成)然后单击标题中的“新建组”按钮或主容器右上角的三个垂直对齐按钮中的一个。这或多或少是正确的,尽管您可能还没有运行“centerpopup”,如果它放在这里。
#backgroundPopup{
display:none;
position: fixed;
_position:absolute; /* hack for internet explorer 6*/
height: 100%;
width: 100%;
top: 0;
left: 0;
background: #000000;
border: 1px solid #cecece;
z-index: 1;
}
#popup_container{
display: none;
position: fixed;
_position:absolute; /* hack for internet explorer 6*/
height: 526px;
width: 718px;
background: url(http://cdn.mojogroups.com/Layout/popup.png) no-repeat !important;
z-index: 2;
color: #000000;
}
//When initializing the page
$(document).ready(function(){
//[...]
popup = new Popup();
popup.initialize();
}
function Popup(){
var popupStatus = 0;
function togglePopup(){
if(popupStatus == 0){
centerPopup();
loadPopup();
}
else
disablePopup();
}
function loadPopup(){
if(popupStatus == 0){
$('#backgroundPopup').css({
"opacity": "0.7"
});
$('#backgroundPopup').fadeIn("fast");
$('#popup_container').fadeIn("fast");
$('body').scrollTop(0);
$('body').css('overflow', 'hidden');
popupStatus = 1;
}
}
this.disablePopup = function(){
if(popupStatus == 1){
$('#backgroundPopup').fadeOut("fast");
$('#popup_container').fadeOut("fast");
$('#popup_container').empty();
$('body').css('overflow', 'auto');
popupStatus = 0;
}
}
function centerPopup(){
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $('#popup_container').height();
var popupWidth = $('#popup_container').width();
$('#popup_container').css({
"position": "absolute",
"top": windowHeight/2 - popupHeight/2,
"left": windowWidth/2 - popupWidth/2
});
$('#backgroundPopup').css({
"height": windowHeight
});
}
this.initialize = function(){
$('#backgroundPopup').click(function(){
popup.disablePopup();
});
$(document).keypress(function(e){
if(e.keyCode==27)
popup.disablePopup();
});
}
this.contacts = function(){
//Fill the popup container...
centerPopup();
loadPopup();
popupDiv.fadeIn('fast');
}