在节目隐藏例程上的Mozilla缓慢 [英] Mozilla slowness on div show hide routine

查看:62
本文介绍了在节目隐藏例程上的Mozilla缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


希望有一些.js /浏览器专家可以帮助解决这个问题。

奇怪的问题。


我做了一个交换div例程,并将事件应用到菜单按钮,菜单后面有一个

更接近的图层。较近的div具有比

子菜单div更低的索引,因此它出现在它们后面。更接近的div包含一个

透明gif,当

moused结束时应用了一个事件来关闭所有div。


问题。


这一切在IE6,Opera7,NN4中运行良好,但在Mozilla浏览器中(NN7 -

Firefox 0.8)它很慢。如果拍得更近的图像,它会变得更慢

更高。我不明白这一点。


这是一个链接,看看发生了什么
http://mysite.verizon.net/res8xvny/menu/


第一页是'n'这么糟糕,因为较近的div / image相对较短

的高度,160px,但第二个例子非常慢,这是因为

更接近div / image高度已增加到400px。除了最近图像的高度

之外,页面是相同的。


这对我来说都很奇怪。我知道问题是因为高度

因为如果我把它变得非常小,那么Mozilla

浏览器的速度非常快。

任何人都知道可能导致这种情况的原因是什么?

没有动画div,只显示隐藏。我已经在代码中添加了一些注释,但它很简单,看看函数中发生了什么。


David

Hi everyone,

Hoping there are some .js/browser experts out there that can help with this
weird problem.

I have made a swap div routine and applied the events to menu buttons with a
closer layer behind the menus. The closer div has a lower index than the
submenu divs so it appears behind them. The closer div contains a
transparent gif with an event applied to it to close all of the divs when
moused over.

The problem.

This all works fine in IE6, Opera7, NN4 but in Mozilla browsers ( NN7 -
Firefox 0.8 ) it is slow. It gets even slower if the closer image is made
taller. I don''t understand this.

Here is a link to see what is going on
http://mysite.verizon.net/res8xvny/menu/

The first page isn''t so bad because the closer div/image is relatively short
in height, 160px, but the 2nd example is very slow and it is because the
closer div/image height has been increased to 400px. Other than the height
of the closer image the pages are identical.

This is all very strange to me. I know the problem is because of the height
because if I make the closer very very small it is very fast in the Mozilla
browsers.

Anyone have an idea what could be causing this? There are no animations on
the divs, just show hides. I have placed some comments in the code but it is
pretty simple to see what is going on in the function.

David

推荐答案

> ...更接近的div包含一个
> ... The closer div contains a
透明gif,当它被覆盖时会应用一个事件来关闭所有div。

问题。<这一切在IE6,Opera7,NN4中运行良好,但在Mozilla浏览器(NN7 -
Firefox 0.8)中它很慢。如果更近的图像更高,它会变得更慢。我不明白这一点。
transparent gif with an event applied to it to close all of the divs when
moused over.

The problem.

This all works fine in IE6, Opera7, NN4 but in Mozilla browsers ( NN7 -
Firefox 0.8 ) it is slow. It gets even slower if the closer image is made
taller. I don''t understand this.




Moz和Firefox似乎总是在进行重新制作,涉及透明的

图像(它们有点慢显着调整大小的图像)。转储

..gif并在DIV中扔一个大小的桌子,它会再次变得活泼。或者

也摆脱了A标签并将事件附加到DIV本身。



Moz and Firefox always seem to bog doing repaints involving transparent
images (they slow a bit with markedly resized images as well). Dump the
..gif and throw a sized table in the DIV and it''ll get snappy again. Or
get rid of the A tag too and attach the event to the DIV itself.


谢谢,这是一个很好的建议,我想到了这个,但是这个脚本

也需要支持NN4。我想我可以在NN4中使用一个

captureEvents(Event.MOUSEOVER)作为div。


我觉得奇怪的是还有其他的show-hide使用这个

方法的例程,甚至比这个更臃肿的脚本并且它们没有表现出这种滞后行为。这就是让我相信脚本本身有一些东西可以借给它的东西。


David

" CharlieDontSurf" <杜********* @ yahoo.com>在消息中写道

新闻:MP ************************ @ News.Individual.NE T ...
Thanks, that''s a good suggestion and I have thought of that but this script
needs to support NN4 as well. I guess I could use a
captureEvents(Event.MOUSEOVER) for the div in NN4.

What I find strange is that there are other show-hide routines using this
method, even scripts that are way more bloated than this one and they do not
exhibit this lagging behavior. That''s what leads me to believe there is
something in the script itself that is lending to this.

David

"CharlieDontSurf" <du*********@yahoo.com> wrote in message
news:MP************************@News.Individual.NE T...
...更接近的div包含一个
透明gif,当moused结束时会应用一个事件来关闭所有div
。 />
问题。

这一切在IE6,Opera7,NN4都可以,但在Mozilla浏览器(NN7 -
Firefox 0.8)中它很慢。如果更近的图像是更高的
,它会变得更慢。我不明白这一点。
... The closer div contains a
transparent gif with an event applied to it to close all of the divs when moused over.

The problem.

This all works fine in IE6, Opera7, NN4 but in Mozilla browsers ( NN7 -
Firefox 0.8 ) it is slow. It gets even slower if the closer image is made taller. I don''t understand this.



Moz和Firefox似乎总是在进行涉及透明图像的重新绘制(它们会因显着调整大小的图像而变慢)。转储
.gif并在DIV中扔一个大小的桌子,它会再次变得活泼。或者也取消A标签并将事件附加到DIV本身。



Moz and Firefox always seem to bog doing repaints involving transparent
images (they slow a bit with markedly resized images as well). Dump the
.gif and throw a sized table in the DIV and it''ll get snappy again. Or
get rid of the A tag too and attach the event to the DIV itself.



David写道:
David wrote:
大家好,

希望有一些.js /浏览器专家可以帮助解决这个奇怪的问题。

问题。

这一切在IE6,Opera7,NN4中运行良好,但在Mozilla浏览器(NN7 -
Firefox 0.8)中它很慢。如果更近的图像更高,它会变得更慢。我不明白这一点。


在Firefox 0.9.3和Mozilla 1.7.2中正常工作。它可能只是早期的一个错误

基于Gecko的浏览器,你将无法避免。

这是一个链接,看看发生了什么
< a rel =nofollowhref =http://mysite.verizon.net/res8xvny/menu/target =_ blank> http://mysite.verizon.net/res8xvny/menu/

任何人都知道可能导致这种情况的原因是什么?
div上没有动画,只是显示隐藏。我在代码中添加了一些注释,但是看看函数中发生了什么很简单。
Hi everyone,

Hoping there are some .js/browser experts out there that can help with this
weird problem.

The problem.

This all works fine in IE6, Opera7, NN4 but in Mozilla browsers ( NN7 -
Firefox 0.8 ) it is slow. It gets even slower if the closer image is made
taller. I don''t understand this.
Works fine in Firefox 0.9.3 and Mozilla 1.7.2. It might just be a bug in earlier
Gecko-based browsers you will be unable to avoid.
Here is a link to see what is going on
http://mysite.verizon.net/res8xvny/menu/

Anyone have an idea what could be causing this? There are no animations on
the divs, just show hides. I have placed some comments in the code but it is
pretty simple to see what is going on in the function.




这个函数:


功能菜单(subToShow,num){

var z,y,activeDrop,close,layers,h =" hidden",v =" visible" ;;

if((y = MM_findObj(" drop0"))!= null){closer =(document .layers)?y:y.style;} //

更接近div。

if((z = MM_findObj(subToShow))!= null){activeDrop =(do cument.layers)?z:z.style} //

活跃的下降div。

for(i = 0; i< 20; i ++){

if((x = MM_findObj(" drop" + [i ]))!= null){subArray =(document.layers)?x:x.style;} //

所有掉落div。

close.visibility = v; //显示更接近。

if(num> 0){

subArray.visibility = h; //隐藏所有其余的。

if(activeDrop){activeDrop.visibility = v} //" show"下降。

}否则{

close.visibility = h; //隐藏更接近。

subArray.visibility = h; //隐藏所有其余的。

}

}

}


编写得非常糟糕。


每次通过循环你都在做'''show show越接近''。同样,每一个

都会通过你正在进行'''show show的循环。下降''。这些东西只需要发生一次即可。
。你循环的唯一原因是''隐藏所有其余的''。

这可能是你应该在循环中做的唯一事情。你每次通过时都设置activeDrop的原因是因为你无条件地一直关闭所有的东西,所以在某些时候你最终会转向
离开你想要的图层的
。同样,无论是否实际存在,您都要检查20层,而不管它们是否存在。同样,你越接近每个

通过循环,但如果num是< 1(无论是什么数字)然后你立即将它关闭

。为了纠正这些缺陷中的至少一些,我修改了

原始功能:


功能菜单(subToShow,num){

var z,y,h =" hidden",v =" visible";

if((y = MM_findObj(" drop0")))= = null){

var closer =(document.layers)? y:y.style;

if(num> 0){

close.visibility = v;

} else {

close.visibility = h;

}

} //更接近div。

if((z = MM_findObj(subToShow) ))!= null){

var activeDrop =(document.layers)? z:z.style;

if(activeDrop&& num> 0){

activeDrop.visibility = v;

}

} //活跃的下降div。

var i = 0;

while((x = MM_findObj(" drop" + i) ))!= null){

if(" drop" + i!= subToShow&& num> 0){

subArray =(document.layers )? x:x.style;

subArray.visibility = h;

}

i ++;

}

}


未经测试,并没有太大改善。但它确实会阻止你从每次鼠标悬停时设置close和activeDrop的可见性20次

某事,这可能是问题。


-

Grant Wagner< gw ***** @ agricoreunited.com>

comp.lang.javascript常见问题 - http://jibbering.com/faq



This function:

function Menu(subToShow,num){
var z,y,activeDrop,closer,layers,h="hidden",v="visible ";
if((y=MM_findObj("drop0"))!=null){closer=(document .layers)?y:y.style;} //
closer div.
if((z=MM_findObj(subToShow))!=null){activeDrop=(do cument.layers)?z:z.style} //
the active drop div.
for(i=0;i<20;i++){
if((x=MM_findObj("drop"+[i]))!=null){subArray=(document.layers)?x:x.style;} //
all of the drop divs.
closer.visibility=v; // "show" the closer.
if(num>0){
subArray.visibility=h; // "hide" all the rest.
if(activeDrop){activeDrop.visibility=v} // "show" the drop.
}else{
closer.visibility=h; // "hide" the closer.
subArray.visibility=h; // "hide" all the rest.
}
}
}

is pretty badly written.

Every pass through the loop you are doing a ''"show" the closer''. As well, every
pass through the loop you are doing a ''"show" the drop''. These things only need
to happen once. The only reason you are looping is to ''"hide" all the rest''.
This is probably the only thing you should be doing in the loop. The reason
you''re setting the activeDrop on every pass is because you are turning
everything off unconditionally all the time, so at some point you end up turning
off the layer you want on. As well, you are checking for 20 layers regardless of
whether they actually exist or not. As well, you turn the closer on with each
pass through the loop, but if num is < 1 (whatever num is) then you turn it off
immediately. To correct at least some of these deficiencies I''ve modified the
original function:

function Menu(subToShow,num){
var z,y,h="hidden",v="visible";
if ((y = MM_findObj("drop0")) != null) {
var closer = (document.layers) ? y : y.style;
if (num > 0) {
closer.visibility = v;
} else {
closer.visibility = h;
}
}// closer div.
if ((z = MM_findObj(subToShow)) != null) {
var activeDrop = (document.layers) ? z : z.style;
if (activeDrop && num > 0) {
activeDrop.visibility = v;
}
} // the active drop div.
var i = 0;
while ((x = MM_findObj("drop" + i)) != null) {
if ("drop" + i != subToShow && num > 0) {
subArray = (document.layers) ? x : x.style;
subArray.visibility = h;
}
i++;
}
}

Untested and it doesn''t improve things very much. But it does stop you from
setting the visibility of closer and activeDrop 20 times everytime you mouseover
something, which is probably the problem.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq


这篇关于在节目隐藏例程上的Mozilla缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆