实现模态对话框有点问题

时间:2009-12-09 17:38:37

标签: javascript jquery

我正在开发一个模式对话框作为Web应用程序的一部分。有一件事对我来说是一个难题。请观看我刚刚在http://inter.freetzi.com/example/上传的电影片段。我非常强烈地认为我必须在视频中附上我的问题,因为这样的情况会更好地看一次,而不是听100次。

(它可以是垂直滚动,也可以是垂直和水平同时。但我在我的例子中使用水平滚动,所以要注意它。)

这是关于我的问题:

透明蒙版的宽度会影响页面本身的宽度。但在Opera中,例如,每次调整窗口大小时,页面的宽度最多接近“true”。在IE中,一旦透明蒙版影响了宽度,之后页面就会记住它并保持不变。有什么问题,如何解决?如何使IE的行为与Opera一样?

在我的项目中,我执行以下操作:

//curViewpointW and curViewpointH are current width and height of the viewpoint (current is meant to be the moment of the resize event) 
oMask.style.width = curViewpointW + 'px';
oMask.style.height = curViewpointH + 'px';      

var pageWH = getPageWH(); //getPageWH() is a function that gets current width and height of the page (with scrolling if there is any)
var curPageW = pageWH[0];
var curPageH = pageWH[1];

if (curPageW > curViewpointW) {
    oMask.style.width = curPageW + 'px';    
} 
if (curPageH > curViewpointH) {
    oMask.style.height = curPageH + 'px';   
}

但IE忽略了某种方式......

P.S。在我的例子中是jQuery,所以很多人可能以前使用过它的对话框。

1 个答案:

答案 0 :(得分:0)

您是否考虑过设置一个onresize事件处理程序,在调整窗口大小时调整掩码尺寸?如果你正在使用Prototype,你可以像这样不显眼地设置这样一个处理程序:

Event.observe(document.onresize ? document : window, "resize", function() {//dostuff});

Roberto Cosenza blog

提供
相关问题