我怎样才能找出脚本是我的设置元素的可见性隐藏? [英] How can I find out what script is setting my element's visibility to hidden?

查看:227
本文介绍了我怎样才能找出脚本是我的设置元素的可见性隐藏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在处理一个复杂的页面有很多不同的脚本的事情,一些ASP.NET AJAX和一些jQuery。

I'm dealing with a complex page with a lot of different scripts going on, some ASP.NET AJAX and some jQuery.

由于某种原因在页面加载时的要素之一有其可见性设置为隐藏。

For some reason when the page loads one of the elements has its visibility set to hidden.

这有什么,有可以告诉我它是什么,是造成这个元素是无形的?甚至一些将停止这是发生在什么剧本是这样做的一切,所以我可以看到它是什么?

Is there anything out there that can tell me what it is that's causing this element to be invisible? Or even something that would stop everything that's happening in whatever script is doing this so I can see what it is?

推荐答案

使用一个DOM检查器(像一个内置的Chrome浏览器)首先确定它是否设置为隐藏,因为一个CSS规则,或者因为它被编程设置为隐藏着一个直接内嵌样式设置。

Use a DOM inspector (like the one built in to Chrome) to first determine if it's set to hidden because of a CSS rule or because it was programmatically set to hidden with a direct inline style setting.

如果它被编程设置为隐藏,然后我唯一知道的是搜索所有的JavaScript code对任何可能被改变的可见性。

If it was programmatically set to hidden, then the only thing I know of is to search all the javascript code for anything that could be changing the visibility.

然后,当你发现code的一些候补线,使用JavaScript调试器(我最喜欢的是内置到Chrome中的一个),每个这些行设置断点。然后,重新加载页面的断点设置后,当这些断点之一被击中,您可以通过code的那部分步骤,看看谁在做。在这一点上,你甚至可以看看调用堆栈,看看code称之为等等。或者,你可以逐步进出这个code到更高水平的调用它和看到他们为什么这样做。

Then, when you find some candidate lines of code, use a javascript debugger (my favorite is the one built into Chrome) and set breakpoints on each of those lines. Then, reload the page after the breakpoints are set and when one of those breakpoints is hit, you can step through that part of the code and see who is doing it. At that point, you can even look at the call stack and see what code called this and so on. Or, you can step through and out of this code into the higher levels that called it and see why they are doing it.

如果它是一个正在隐藏它的CSS规则,那么你需要看看是什么原因引发的CSS规则(类,标识等),并找出如何改变一个或另一个让你想要的对象不是由CSS规则隐藏。请记住,类可以通过JavaScript被添加/删除从DOM对象,这样也可能是原因的一部分。

If it is CSS rules that are making it hidden, then you need to look at what triggers those CSS rules (classes, IDs, etc...) and figure out how to change one or the other so that your desired object isn't hidden by that CSS rule. Remember that classes can be added/removed from objects in the DOM via javascript so that could also be part of the cause.

这篇关于我怎样才能找出脚本是我的设置元素的可见性隐藏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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